how can i calculate median thru a SQL QUERY. To the query below, I need to add MEDIAN(TOTAL_HOURS) for each HRID.
Please help.
My query is as follows:
SELECT A.HRID,
LTRIM(RTRIM(A.LAST_NAME)) || ', '||LTRIM(RTRIM(A.FIRST_NAME)) || ' '||LTRIM(RTRIM(A.MIDDLE_NAME)) AS EMPLOYEE_NAME,
NVL(SUM(B.TOTAL_HOURS),0) AS TOTAL_HOURS,
COUNT(B.HRID) AS TOTAL_COUNT,
E.SUPERVISOR_HRID,
A.MRG,
E.MANAGER_HRID,
E.DISTRICT_HRID,
E.DIVISION_HRID
FROM A,
B,
E
WHERE A.HRID = B.HRID(+)
AND A.HRID = E.HRID
AND B.ATTENDANCE_START_DATE >= TO_DATE(FROM_DATE,'MM/DD/YYYY')
AND B.ATTENDANCE_START_DATE <= TO_DATE(T_DATE,'MM/DD/YYYY')
GROUP BY A.HRID,
LTRIM(RTRIM(A.LAST_NAME)) || ', '||LTRIM(RTRIM(A.FIRST_NAME)) || ' '||LTRIM(RTRIM(A.MIDDLE_NAME)),
E.SUPERVISOR_HRID,
A.MRG,
E.MANAGER_HRID,
E.DISTRICT_HRID,
E.DIVISION_HRID
ORDER BY EMPLOYEE_NAME;
Please help. Thanks.
Please help.
My query is as follows:
SELECT A.HRID,
LTRIM(RTRIM(A.LAST_NAME)) || ', '||LTRIM(RTRIM(A.FIRST_NAME)) || ' '||LTRIM(RTRIM(A.MIDDLE_NAME)) AS EMPLOYEE_NAME,
NVL(SUM(B.TOTAL_HOURS),0) AS TOTAL_HOURS,
COUNT(B.HRID) AS TOTAL_COUNT,
E.SUPERVISOR_HRID,
A.MRG,
E.MANAGER_HRID,
E.DISTRICT_HRID,
E.DIVISION_HRID
FROM A,
B,
E
WHERE A.HRID = B.HRID(+)
AND A.HRID = E.HRID
AND B.ATTENDANCE_START_DATE >= TO_DATE(FROM_DATE,'MM/DD/YYYY')
AND B.ATTENDANCE_START_DATE <= TO_DATE(T_DATE,'MM/DD/YYYY')
GROUP BY A.HRID,
LTRIM(RTRIM(A.LAST_NAME)) || ', '||LTRIM(RTRIM(A.FIRST_NAME)) || ' '||LTRIM(RTRIM(A.MIDDLE_NAME)),
E.SUPERVISOR_HRID,
A.MRG,
E.MANAGER_HRID,
E.DISTRICT_HRID,
E.DIVISION_HRID
ORDER BY EMPLOYEE_NAME;
Please help. Thanks.