2014-03-05,GENShift,离开 i想要像这个合成只有 Att_Scheduleshift,Absent,present .................. ........................................ Genshift, 5,1 NIGHTshift,2,0 解决方案 检查以下查询中的列名和表名 选择 Att_Date,Att_ScheduledShift,' absent' = case when att_status = ' 缺席' 然后 count(att_status) else 0 end ,' present' = case att_status = ' present' 然后 count(att_status) else 0 end 来自出席 group by Att_ScheduledShift,Att_Date,att_status 你最好使用att_status作为整数0和1 Att_Date , Att_ScheduledShift , att_status...................................................................................2014-01-01 , GENShift , Absent2014-02-04 , NIGHTshift , present2014-03-05 , GENShift , leavei want out put like this formate onlyAtt_Scheduleshift , Absent , present..........................................................Genshift , 5 , 1NIGHTshift , 2 , 0 解决方案 check the column name and table name at the below queryselect Att_Date ,Att_ScheduledShift ,'absent'=case when att_status ='absent' then count(att_status)else 0 end ,'present'=case when att_status ='present' then count(att_status) else 0 end from Attendance group by Att_ScheduledShift ,Att_Date ,att_statusbetter you use att_status as integer 0 and 1 这篇关于在SQL Server中按分组分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 20:57