在下面的数据透视表中,我无法按日期订购。请帮助我。
Ex: - 11月,12月,1月
select *
from
(
select
Dsgn_Entered_By,
COUNT(ddif_number) DDIF_Number,
SUBSTRING(DATENAME(MONTH,Entered_Date),0,10) as Date,
DATEPART(mm,Entered_Date) Entered_Date
from Design_Entry_Fixture_Input
group by Entered_Date,Dsgn_Entered_By
)
yy
PIVOT
(
SUM(DDIF_Number)
for Dsgn_Entered_By IN ([chandru.r],[praveen.n],[CHETAN B],[HANUMANTH REDDY],[PRAVEEN NAIK],[saravana.k],[Yogitha])
)PVT
order by Entered_Date
答案 0 :(得分:0)
试试这个:
select *
from
(
select *
from
(
select
Dsgn_Entered_By,
COUNT(ddif_number) DDIF_Number,
SUBSTRING(DATENAME(MONTH,Entered_Date),0,10) as Date,
DATEPART(mm,Entered_Date) Entered_Date
from Design_Entry_Fixture_Input
group by Entered_Date,Dsgn_Entered_By
)
yy
PIVOT
(
SUM(DDIF_Number)
for Dsgn_Entered_By IN ([chandru.r],[praveen.n],[CHETAN B],[HANUMANTH REDDY],[PRAVEEN NAIK],[saravana.k],[Yogitha])
)PVT ) t
order by Entered_Date