好的,我正在尝试制作一份包含两个不同日期的人数报告。该报告基本上将计算符合列标准的活跃人数。如果我基本上将脚本切成两半并一次运行一个日期,则该报告有效。我正在尝试获得一个多合一的脚本。
这是我到目前为止所拥有的:
SELECT DISTINCT
CONCAT(CONCAT(CONCAT(CONCAT(EJOB1.EJBU, ' / ' ), Jobby1.EJDBU ),' ' ), (CASE WHEN CODE1.JB3 IN 'Y' THEN 'QBR' ELSE 'Non-QBR' END)) AS "BU / DBU START",
COUNT(CONCAT(CONCAT(Jobby1.EJBU, ' ' ), Jobby1.EJDBU)) AS "HC START",
CONCAT(CONCAT(CONCAT(CONCAT(Jobby2.EJBU, ' / ' ), Jobby2.EJDBU ),' ' ), (CASE WHEN CODE2.JB3 IN 'Y' THEN 'QBR' ELSE 'Non-QBR' END)) AS "BU / DBU END",
COUNT(CONCAT(CONCAT(Jobby2.EJBU, ' ' ), Jobby2.EJDBU)) AS "HC END"
FROM Blah.SNARL SNARL1
JOIN Blah.Candy Candy1
ON SNARL1.EBFLXID = Candy1.EEFLXIDEB
JOIN Blah.Jobby Jobby1
ON SNARL1.EBFLXID = Jobby1.EJFLXIDEB
JOIN Blah.CODE CODE1
ON Jobby1.EJJOBCODE = JOBCODE1.JBJOBCODE,
Blah.SNARL SNARL2
JOIN Blah.Candy Candy2
ON SNARL2.EBFLXID = Candy2.EEFLXIDEB
JOIN Blah.Jobby Jobby2
ON SNARL2.EBFLXID = Jobby2.EJFLXIDEB
JOIN Blah.CODE CODE2
ON Jobby2.EJCODE = CODE2.JB
WHERE SNARL1.EBFLAGEMP = 'Y'
AND Candy1.EESTATUS != 'Terminated'
AND (Candy1.EEDATEBEG <= TO_DATE(:FROM_date, 'mm-dd-yyyy')
AND (Candy1.EEDATEEND >= TO_DATE(:FROM_date, 'mm-dd-yyyy')
OR Candy1.EEDATEEND IS NULL))
AND (Jobby1.EJDATEBEG <= TO_DATE(:FROM_date, 'mm-dd-yyyy')
AND (Jobby1.EJDATEEND >= TO_DATE(:FROM_date, 'mm-dd-yyyy')
OR Jobby1.EJDATEEND IS NULL))
AND SNARL2.EBFLAGEMP = 'Y'
AND Candy2.EESTATUS != 'Terminated'
AND (Candy2.EEDATEBEG <= TO_DATE(:TO_date, 'mm-dd-yyyy')
AND (Candy2.EEDATEEND >= TO_DATE(:TO_date, 'mm-dd-yyyy')
OR Candy2.EEDATEEND IS NULL))
AND (Jobby2.EJDATEBEG <= TO_DATE(:TO_date, 'mm-dd-yyyy')
AND (Jobby2.EJDATEEND >= TO_DATE(:TO_date, 'mm-dd-yyyy')
OR Jobby2.EJDATEEND IS NULL))
GROUP BY (Jobby1.EJBU, Jobby1.EJDBU, CODE1.JB3),( Jobby2.EJBU,Jobby2.EJDBU, CODE2.JB3)