要按照GSH筛选出01的YUE 和xsje
select GSH,YUE,cast(xsje as decimal(10,2)) as xsje
 from (select GSH,yue,SUM(XSJE)/10000000 as xsje from (
select GSH,DATEPART(MONTH,SWRQ) as yue,XSJE
from BBHLH
where SWRQ > = '2011/01/01'
and SWRQ < '2012/01/01') as tbl
group by GSH,yue) as tbl
order by GSH,yue
查询结果如下:SQLselect