#2
mywisdom882022-04-15 08:36
|
select * from
(select clientid,nf=datepart(yy,billdate),yf=datepart(mm,billdate),je=sum(totalamt) from invoice GROUP BY clientid,datepart(yy,billdate),datepart(mm,billdate)) as #tt
PIVOT(sum(je) FOR yf IN([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) AS PVT