Advertisement
Advertisement
| 07.17.2008 at 06:14AM PDT, ID: 23573054 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: |
****************************************************************************
1rst EXAMPLE:
**************************************
SELECT DeptName, sum(ThisMonthRec) AS ReceivedThisMonth, sum(RollingAvg) AS RollingAverage, sum(YearToDatTtl) AS YearToDateRec
FROM
(SELECT
request_dept_nm AS DeptName,
Count(request_dept_nm) AS ThisMonthRec,
NULL AS RollingAvg,
NULL AS YearToDatTtl
FROM request_fact
WHERE requested_dt BETWEEN Forms!frmRSS_TtlsByFrq!cmbMonthBeg AND Forms!frmRSS_TtlsByFrq!cmbMonthEnd
GROUP BY request_dept_nm
UNION ALL
SELECT
request_dept_nm AS DeptName,
NULL AS ThisMonthRec,
Round((Count(request_dept_nm))/12) As RollingAvg,
NULL AS YearToDatTtl
FROM request_fact
WHERE requested_dt BETWEEN DateDiff("m", -12, Forms!frmRSS_TtlsByFrq!cmbMonthEnd) AND Forms!frmRSS_TtlsByFrq!cmbMonthEnd
GROUP BY request_dept_nm)
GROUP BY DeptName;
****************************************************************************
2nd EXAMPLE:
**************************************
SELECT DeptName, sum(ThisMonthRec) AS ReceivedThisMonth, sum(RollingAvg) AS RollingAverage, sum(YearToDatTtl) AS YearToDateRec
FROM
(SELECT
request_dept_nm AS DeptName,
Count(request_dept_nm) AS ThisMonthRec,
NULL AS RollingAvg,
NULL AS YearToDatTtl
FROM request_fact
WHERE requested_dt BETWEEN Forms!frmRSS_TtlsByFrq!cmbMonthBeg AND Forms!frmRSS_TtlsByFrq!cmbMonthEnd
GROUP BY request_dept_nm
UNION ALL
SELECT
request_dept_nm AS DeptName,
NULL AS ThisMonthRec,
Round((Count(request_dept_nm))/12) As RollingAvg,
NULL AS YearToDatTtl
FROM request_fact
WHERE requested_dt BETWEEN DateDiff("m", -12, Forms!frmRSS_TtlsByFrq!cmbMonthEnd) AND Forms!frmRSS_TtlsByFrq!cmbMonthEnd
GROUP BY request_dept_nm
UNION ALL
SELECT
request_dept_nm AS DeptName,
NULL AS ThisMonthRec,
NULL As RollingAvg,
Count(request_dept_nm) As YearToDatTtl
FROM request_fact
WHERE requested_dt BETWEEN #06/01/2008# AND #06/30/2008#
GROUP BY request_dept_nm)
GROUP BY DeptName;
|