本文介绍了部门明智的数据与集合功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hii, 我想要部门明智的数据, 这是我试过的...但我认为我做错了。我想要的是..部门IT部门有多少目标,在IT部门生活,完成..其他部门也是如此 选择 distinct DepartmentName,TotalLive,TotalDraft,TotalCompleted 来自 ( 选择 d.departmentName,(选择 count(*)来自目标其中 objective_Status = 1) AS TotalLive,(选择 count(*)来自目标其中 objective_Status = 2) AS TotalDraft,( select count(*)来自目标其中 objec tive_Status = 3) AS TotalCompleted 来自员工 as e 内部 join 部门 as d on e.DepartmentId = d.DepartmentId )a 我想要的是 部门名称|完成总数|总生活|总草案 IT 35 40 45 管理员55 39 41 解决方案 尝试: SELECT d.departartmentName, SUM( CASE WHEN e.objective_Status = 1 那么 1 ELSE 0 END ) AS TotalLive, SUM( CASE WHEN e.objective_Status = 2 那么 1 ELSE 0 END ) AS TotalDraft, SUM( CASE WHEN e.objective_Status = 3 那么 1 ELSE 0 END ) AS TotalCompleted FROM 员工e JOIN 部门d ON e.DepartmentId = d。 DepartmentId GROUP BY departmentName Hii , I want department wise data ,this is what i tried .. but i think i made something wrong in it . What i want is .. How many objectives in department IT , live , completed in IT section .. same for other departments select distinct DepartmentName,TotalLive,TotalDraft,TotalCompletedfrom(select d.departmentName,(select count(*) from objectives where objective_Status=1) AS TotalLive,(select count(*) from objectives where objective_Status=2) AS TotalDraft,(select count(*) from objectives where objective_Status=3) AS TotalCompletedfrom Employee as e inner join Departments as don e.DepartmentId = d.DepartmentId)aWhat i want is Department Name | Total Completed | Total Live | Total DraftIT 35 40 45Admin 55 39 41 解决方案 Try:SELECT d.departartmentName, SUM(CASE WHEN e.objective_Status=1 THEN 1 ELSE 0 END) AS TotalLive, SUM(CASE WHEN e.objective_Status=2 THEN 1 ELSE 0 END) AS TotalDraft, SUM(CASE WHEN e.objective_Status=3 THEN 1 ELSE 0 END) AS TotalCompletedFROM Employee eJOIN Departments dON e.DepartmentId = d.DepartmentIdGROUP BY departmentName 这篇关于部门明智的数据与集合功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-01 09:38