每人每个月有好几笔奖金都算在一个字段里,现在要汇总出每人1-12个月每月的奖金总额
应该怎么写呢?
再具体点,有这样一张表
id date bouns
现在要查询2006年度每人每个月的奖金总额?怎么写?谢了
应该怎么写呢?
再具体点,有这样一张表
id date bouns
现在要查询2006年度每人每个月的奖金总额?怎么写?谢了
解决方案 »
- 请帮忙解决跨表查询的问题
- 菜鸟出问题,请高手帮帮忙!
- oracle 数据转换SQL 问题???
- sql sever 2005附加数据库时出错。有关详细信息,请单击“消息”列中的超链接。
- 请问6.5的备份文件是不是.dup后缀名?
- 求一语句
- 这个Update trigger应该怎么写?
- 在存储过程中更新TEXT类型的字段,系统提示指针的无效性,问题出在什么地方?
- 一个困饶我很久的问题,怎样使几个数据库保持自动同步?(解决问题200分相送)
- 使非管理员帐户来执行xp_cmdshell扩展存储过程
- 分不清楚是导出数据还是备份数据
- 想写一个可以判断某个ID在其它表里有没有被用的函数,但一直不成功,各位有空看看吗?
from tablename
where year(date)='2006'
group by id,month(date)
insert into taba select 1,'2006-1-1',100
union all select 1,'2006-1-1',100
union all select 1,'2006-1-4',100
union all select 1,'2006-1-1',100
union all select 1,'2007-12-1',100
union all select 1,'2007-1-12',100
union all select 2,'2006-1-1',100
union all select 1,'2006-1-1',100
union all select 2,'2006-1-1',100
union all select 1,'2006-1-1',100
union all select 2,'2006-1-1',100
union all select 1,'2006-3-1',100
union all select 1,'2006-3-11',100
union all select 3,'2006-1-1',100
union all select 1,'2006-1-1',100
union all select 3,'2007-7-1',100
go
select id,CONVERT(varchar(6),date,112)as date,sum(bouns)as bouns
from taba group by id,CONVERT(varchar(6),date,112)