How can I combine 2 queries?

前端 未结 3 1177
猫巷女王i
猫巷女王i 2021-01-29 08:34

I have these below queries in fastreport. I would like to combine them together into one query. How can I do this ?

SELECT 
    EAMEMID, COUNT (EAMATTNSTATUS)/2          


        
3条回答
  •  囚心锁ツ
    2021-01-29 09:22

    You can use conditional aggregation:

    SELECT EAMEMID,
           SUM(CASE WHEN EAMATTNSTATUS in (7, 8) THEN 1 ELSE 0 END) / 2 as ABSENTDAYS1,
           COUNT(DISTINCT CASE WHEN EAMATTNSTATUS in (6) THEN EAMDATE
                 END) as ABSENTDAYS  
    FROM viewDAILYSUM  
    WHERE (EAMEMID = :EAMEMID) AND
          (EAMDATE between :FDate and :TDate)
    GROUP BY EAMEMID  
    ORDER BY EAMEMID
    

提交回复
热议问题