sql查询单个项目的全年总和,按月份统计怎么实现?
select sum(salary.salary), dept from salary, staff
where salary.staffid = staff.staffid and salary.[date] = "2010-7-2"
group by staff.dept
select
m.dept ,
convert
(
varchar
(7),n.
date
,120) yue,
sum
(n.salary)
from
staff m, salary n
where
m.staffid = n.staffid
and
month
(n.
date
) = 7
group
by
m.dept ,
convert
(
varchar
(7),n.
date
,120)
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: 自定义EL表达式,将对象转成json格式,关键代码
- 下一篇: yii框架文件缓存