table1里有两列,日期列和ID 列,我根据传进来的参数2012查与日期列相同的日期只有年分,获取了2012-1-12 10:15:00,
2012-2-12 10:15:00等许多,怎么把读到的数据的月份取出来并分组,如1,2,3,4,5,6。。。急急急,在线等
------解决方案--------------------
- SQL code
declare @riqi int=2012select convert(varchar(7),a.riqi,120),sum(b.[金额]) as total from table1 as a with(nolock) inner join table2 as b with(nolock) on a.id=b.idwhere datepart(a.riqi)[email protected]group by convert(varchar(7),a.riqi,120)