数据库记录了1-12月份每个员工的加班情况,
记录表的结构:加班记录id --加班员工id --加班时间
现在想得到一份统计列表,
前台页面结构如下,
月份 实加班 应加班 存休
1月份 4 ?天
2月份 4 ?天
3月份 4 ?天
4月份 4 ?天
5月份 4 ?天
6月份 4 ?天
7月份 4 ?天
8月份 4 ?天
9月份 4 ?天
10月份 4 ?天
11月份 4 ?天
12月份 4 ?天 求一个比较好的方式,得到员工1-12月份的实加班情况统计。
记录表的结构:加班记录id --加班员工id --加班时间
现在想得到一份统计列表,
前台页面结构如下,
月份 实加班 应加班 存休
1月份 4 ?天
2月份 4 ?天
3月份 4 ?天
4月份 4 ?天
5月份 4 ?天
6月份 4 ?天
7月份 4 ?天
8月份 4 ?天
9月份 4 ?天
10月份 4 ?天
11月份 4 ?天
12月份 4 ?天 求一个比较好的方式,得到员工1-12月份的实加班情况统计。
解决方案 »
- 跪求ms chart教程或者开发文档
- vs2010做。net 4.0的项目,为什么会这么多警告提示呢,百度找不到
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许
- 急急,帮看看这个问题
- ASP.NET使用表单上传文件的 问题
- 菜鸟问有关asp.net中修改密码控件问题
- 关于用户控件中图片的路径
- 设计模式????????? CS+BS
- 關於訪問次數的問題
- 我想在网站上做一个信息发布系统,非常简单即可,只要实现简单的添加删除即可,请建议?
- aspx页面文件下载问题
- ASP.NET怎么在table里读取数据
select 加班员工id,sum(加班时间) from table group by 加班员工id,datepart(month,date)
这样得到员工每个月的加班时间
select
'数量' as ' ',
sum(case month(日期) when 1 then 数量 else 0 end) as [一月],
sum(case month(日期) when 2 then 数量 else 0 end) as [二月],
sum(case month(日期) when 3 then 数量 else 0 end) as [三月],
sum(case month(日期) when 4 then 数量 else 0 end) as [四月]
from tb
http://topic.csdn.net/u/20080829/13/3d1eabe0-c558-4f8c-a373-b060af66e2eb.html
--by Month
declare @time1 datetime, @time2 datetime
set @time1='2009-11-14'
set @time2='2009-11-14'
select convert(varchar(7),k.rn+@time1-1,120) as Date ,isnull(sum(GetMoney),0) as GetMoney
from AgentAmountLog a right join
(select ROW_NUMBER() over(order by getdate()) as rn from sys.columns a ,sys.columns b) k
on DATEDIFF(DAY,a.LogTime,k.rn+@time1-1)=0
where k.rn+@time1-1<=@time2
group by convert(varchar(7),k.rn+@time1-1,120)
order by Date
insert into @table values('1','2009-01-02')
insert into @table values('1','2009-02-01')
insert into @table values('1','2009-03-01')
insert into @table values('1','2009-04-01')
insert into @table values('1','2009-05-01')
insert into @table values('1','2009-06-01')
insert into @table values('1','2009-07-01')
insert into @table values('1','2009-08-01')
insert into @table values('1','2009-09-01')
insert into @table values('1','2009-10-01')
insert into @table values('1','2009-11-01')
insert into @table values('1','2009-12-01')
insert into @table values('2','2009-12-01')select
case month(加班时间) when 1 then '一月'
when 2 then '二月'
when 3 then '三月'
when 4 then '四月'
when 5 then '五月'
when 6 then '六月'
when 7 then '七月'
when 8 then '八月'
when 9 then '九月'
when 10 then '十月'
when 11 then '十一月'
when 12 then '十二月' end as 月份,
sum(1) as 加班次数
from @table
where 加班员工id='1'
group by month(加班时间)
最后表格一列显示累计就可以了
这个显示1使用模板2我觉得直接后台输出更方便更直接些
http://blog.csdn.net/xianfajushi/archive/2009/07/22/4371397.aspx
难道你还打算使用临时表来储存你的统计数据加快检索时间?
是加班发生在哪一天?还是加班了几个小时或者是几天?如果是加班时间是datetime类型(加班发生在哪一天) 那6楼完全正解 。
如果加班时间是数值类型的 那一楼的正解 ,也就是说肯定要有时间字段 ,