Table - T1 (id, Description)
Table - T2 (id, fk_id,Dates, Amount)
select d.Description,dt.Dates,dt.Amount
from T2 as dt join T1 d
on
d.id = dt.fk_id
group by d.Description,dt.Dates,dt.Amount
在上面运行查询结果显示如下
Description Dates Amount
nutrition1 2012-01-01 100.00
nutrition1 2013-01-01 100.00
nutrition2 2012-01-01 100.00
nutrition2 2013-01-01 600.00
nutrition3 2012-01-01 300.00
nutrition3 2013-01-01 700.00
nutrition4 2012-01-01 400.00
nutrition4 2013-01-01 800.00
nutrition5 2012-01-01 300.00
nutrition5 2013-01-01 600.00
我想将结果显示为
Description 01-01-2012 01-01-2013
nutrition1 100 100
nutrition2 100 600
nutrition3 300 700
nutrition4 400 800
nutrition5 300 600
日期会改变