首页 新闻 搜索 专区 学院

sql分类汇总的问题 急求!!!!!!

0
悬赏园豆:100 [已解决问题] 解决于 2012-04-27 11:15

SELECT [text] as 请假类别, UserName AS 姓名, DepartName AS 部门, sum(LeaveDay) AS 总时间 FROM V_EcLeave
GROUP BY [text],UserName,DepartName

 

这是我的查询语句,但是我想实现如下图的查询效果

每一行是一条查询出来的数据

大侠们赶紧来帮下忙!!!一百豆急求送出

edsonwu的主页 edsonwu | 初学一级 | 园豆:146
提问于:2012-04-27 10:53
< >
分享
最佳答案
0

SELECT UserName AS 姓名, DepartName AS 部门, sum(LeaveDay) AS 总时间,

count(case [text] when '事假' then 0 end) as 事假,

count(case [text] when '病假' then 0 end) as 病假,

count(case [text] when '年假' then 0 end) as 年假,

count(case [text] when '婚假' then 0 end) as 婚假,

count(case [text] when '事假' then 0 end) as 事假,

count(case [text] when '事假' then 0 end) as 事假,

后面的就不写了  和前面一样

 

FROM V_EcLeave  grouop by userName,DepartName

 

收获园豆:100
┢┦偉 | 小虾三级 |园豆:1240 | 2012-04-27 11:05
其他回答(1)
0

select departname as 部门,职位,Username as 姓名,

count(decode([text],'事假',leaveday,0) )as 事假,

count(decode([text],'病假',leaveday,0))as 病假,

count(decode([text],'年假',leaveday,0))as 年假,

count(decode([text],'婚假',leaveday,0))as 婚嫁,

count(decode([text],'丧假',leaveday,0))as 丧假,

count(decode([text],'产假',leaveday,0))as 产假,

count(decode([text],'计划生育假',leaveday,0))as 计划生育假,

count(decode([text],'正假',leaveday,0))as 正假

group by departName,username,职位

xjyang | 园豆:212 (菜鸟二级) | 2012-04-27 11:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册