我在fastreport中有以下这些查询。我想通过输入一个查询来总结这两个查询的答案..任何人都可以帮忙吗?
SELECT
EAMEMID, COUNT (EAMATTNSTATUS)/2 as ABSENTDAYS1
FROM
viewDAILYSUM
WHERE
(EAMEMID = :EAMEMID)
AND (EAMDATE BETWEEN :FDate AND :TDate)
AND (EAMATTNSTATUS IN (7, 8))
GROUP BY
EAMEMID
ORDER BY
EAMEMID
SELECT
EAMEMID, COUNT(DISTINCT EAMDATE) ABSENTDAYS
FROM
viewDAILYSUM
WHERE
(EAMEMID = :EAMEMID)
AND (EAMDATE BETWEEN :FDate AND :TDate)
AND (EAMATTNSTATUS IN (6))
GROUP BY
EAMEMID
ORDER BY
EAMEMID
答案 0 :(得分:0)
试试这个:
SELECT EAMEMID, SUM(ABSENTDAYS) AS ABSENTDAYS FROM (
SELECT EAMEMID, COUNT (EAMATTNSTATUS)/2 as ABSENTDAYS
FROM viewDAILYSUM
WHERE (EAMEMID = :EAMEMID)
AND (EAMDATE BETWEEN :FDate AND :TDate)
AND (EAMATTNSTATUS IN (7, 8))
GROUP BY EAMEMID
UNION ALL
SELECT EAMEMID, COUNT(DISTINCT EAMDATE) ABSENTDAYS
FROM viewDAILYSUM
WHERE (EAMEMID = :EAMEMID)
AND (EAMDATE BETWEEN :FDate AND :TDate)
AND (EAMATTNSTATUS IN (6))
GROUP BY EAMEMID
)
GROUP BY EAMEMID
ORDER BY EAMEMID