欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-05-05 21:22:48
...
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;