SELECT [text] as 请假类别, UserName AS 姓名, DepartName AS 部门, sum(LeaveDay) AS 总时间 FROM V_EcLeave
GROUP BY [text],UserName,DepartName
这是我的查询语句,但是我想实现如下图的查询效果
每一行是一条查询出来的数据
大侠们赶紧来帮下忙!!!一百豆急求送出
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
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,职位