SQL多重条件查询求和分组语句

select sum(d.Y_TS) as ts ,sum(d.y_jb) as jb, sum(d.Y_TS)/sum(d.y_jb)*100 as bfb,d.DEPT_ID  from e_data d
where d.CREATE_DATE >= '2012-01-11' and d.CREATE_DATE <= '2013-01-01'
GROUP BY d.DEPT_ID  ORDER BY ts desc LIMIT 5;

猜你喜欢

转载自taozhu551.iteye.com/blog/1615762