Hi guys can appologies for the messy query but can anyone spot the error. It says from keyword not found where expected. Also can someone tell me if the second query is valid as i thought i could reference the names of previous AS "Blah" statements in following calculations.
query2
Code:
SELECT O.OBJECT_NAME,
T.DATE_YYYYMMDD,
V.T_LOGIN,
SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK) AS NOT_READY,
V.T_TALK,
V.T_WAIT,
CR14R1V.T_ACW,
V.T_HOLD,
V.T_OUTBOUND,
SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER) AS AUX,
SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH) AS BREAK_LUNCH,
(V.T_LOGIN / 60) / 60 AS TOTAL_STAFF_TIME_HR,
((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK)) / 60) / 60 AS TOTAL_NOT_READY_HR,
(V.T_TALK / 60) / 60 AS TOTAL_TALK_HR,
(V.T_WAIT / 60) / 60 AS TOTAL_WAIT_HR,
(CR14R1V.T_ACW / 60) / 60 AS TOTAL_ACW_HR,
(V.T_HOLD / 60) / 60 AS TOTAL_HOLD_HR,
(V.T_OUTBOUND / 60) / 60 AS TOTAL_OUTBOUND_HR,
((SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / 60) / 60 AS TOTAL_AUX_HR,
((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH))/ 60) / 60 AS TOTAL_BREAK_LUNCH_HR,
((V.T_LOGIN / 60) / 60) / 5.4 AS TOTAL_STAFF_TIME_FTE,
(((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK)) / 60) / 60)) / 5.4 AS TOTAL_NOT_READY_FTE,
((V.T_TALK / 60) / 60) / 5.4 AS TOTAL_TALK_FTE,
((V.T_WAIT / 60) / 60) / 5.4 AS TOTAL_WAIT_FTE,
((CR14R1V.T_ACW / 60) / 60) / 5.4 AS TOTAL_ACW_FTE,
((V.T_HOLD / 60) / 60) / 5.4 AS TOTAL_HOLD_FTE,
((V.T_OUTBOUND / 60) / 60) / 5.4 AS TOTAL_OUTBOUND_FTE,
(((SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / 60) / 60) / 5.4 AS TOTAL_AUX_FTE,
(((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH))/ 60) / 60) / 5.4 AS TOTAL_BREAK_LUNCH_FTE,
(V.T_TALK + V.T_WAIT + V.T_HOLD)/(V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_STAFF_UTIL_PERCENT,
NOT_READY / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_NOT_READY_UTIL_PERCENT,
V.T_TALK / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_TALK_UTIL_PERCENT,
V.T_WAIT / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_WAIT_UTIL_PERCENT,
CR14R1V.T_ACW / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_ACW_UTIL_PERCENT,
V.T_HOLD / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_HOLD_UTIL_PERCENT,
V.T_OUTBOUND / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_OUTBOUND_UTIL_PERCENT,
(SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_AUX_UTIL_PERCENT,
SUM ((((V.T_TALK / 60) / 60) / 5.4) + (((V.T_WAIT / 60) / 60) / 5.4) + (((V.T_HOLD / 60) / 60) / 5.4)) AS STAFF_TIME_AVAIL_FTE
FROM ((DATAMART01.O_CR60_AG_DAY CR60O INNER JOIN DATAMART01.V_CR60_AG_DAY CR60V ON CR60O.OBJECT_ID = CR60V.OBJECT_ID)
INNER JOIN DATAMART01.T_CR60_AG_DAY CR60T ON CR60V.TIME_KEY = CR60T.TIME_KEY)
INNER JOIN (((DATAMART01.O_GROFAGS_DAY O INNER JOIN DATAMART01.V_GROFAGS_DAY V ON O.OBJECT_ID = V.OBJECT_ID)
INNER JOIN DATAMART01.T_GROFAGS_DAY T ON V.TIME_KEY = T.TIME_KEY)
INNER JOIN ((DATAMART01.O_CR14R1_AG_DAY CR14R1O
INNER JOIN DATAMART01.V_CR14R1_AG_DAY CR14R1V ON CR14R1O.OBJECT_ID = CR14R1V.OBJECT_ID)
INNER JOIN DATAMART01.T_CR14R1_AG_DAY CR14R1T ON CR14R1V.TIME_KEY = CR14R1T.TIME_KEY)
ON (T.TIME_KEY = CR14R1T.TIME_KEY) AND (V.OBJECT_ID = CR14R1V.OBJECT_ID))
ON (CR60T.TIME_KEY = T.TIME_KEY) AND (CR60V.OBJECT_ID = V.OBJECT_ID)
WHERE (((O.OBJECT_NAME)='ALL_AG_SHOP') AND ((T.DATE_YYYYMMDD)='20080203'));
query2
Code:
SELECT O.OBJECT_NAME, T.DATE_YYYYMMDD,
V.T_LOGIN,
SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK) AS NOT_READY,
V.T_TALK,
V.T_WAIT, CR14R1V.T_ACW,
V.T_HOLD, V.T_OUTBOUND,
SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER) AS AUX,
SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH) AS BREAK_LUNCH,
(V.T_LOGIN / 60) / 60 AS TOTAL_STAFF_TIME_HR,
((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK)) / 60) / 60 AS TOTAL_NOT_READY_HR,
(V.T_TALK / 60) / 60 AS TOTAL_TALK_HR,
(V.T_WAIT / 60) / 60 AS TOTAL_WAIT_HR,
(CR14R1V.T_ACW / 60) / 60 AS TOTAL_ACW_HR,
(V.T_HOLD / 60) / 60 AS TOTAL_HOLD_HR,
(V.T_OUTBOUND / 60) / 60 AS TOTAL_OUTBOUND_HR,
((SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / 60) / 60 AS TOTAL_AUX_HR,
((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH))/ 60) / 60 AS TOTAL_BREAK_LUNCH_HR,
((V.T_LOGIN / 60) / 60) / 5.4 AS TOTAL_STAFF_TIME_FTE,
(((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH + AUX + V.T_OUTBOUND + V.T_HOLD + CR14R1V.T_ACW + V.T_WAIT + V.T_TALK)) / 60) / 60)) / 5.4 AS TOTAL_NOT_READY_FTE,
((V.T_TALK / 60) / 60) / 5.4 AS TOTAL_TALK_FTE,
((V.T_WAIT / 60) / 60) / 5.4 AS TOTAL_WAIT_FTE,
((CR14R1V.T_ACW / 60) / 60) / 5.4 AS TOTAL_ACW_FTE,
((V.T_HOLD / 60) / 60) / 5.4 AS TOTAL_HOLD_FTE,
((V.T_OUTBOUND / 60) / 60) / 5.4 AS TOTAL_OUTBOUND_FTE,
(((SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / 60) / 60) / 5.4 AS TOTAL_AUX_FTE,
(((SUM (CR14R1V.T_BREAK + CR14R1V.T_LUNCH))/ 60) / 60) / 5.4 AS TOTAL_BREAK_LUNCH_FTE,
(V.T_TALK + V.T_WAIT + V.T_HOLD)/(V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_STAFF_UTIL_PERCENT,
NOT_READY / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_NOT_READY_UTIL_PERCENT,
V.T_TALK / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_TALK_UTIL_PERCENT,
V.T_WAIT / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_WAIT_UTIL_PERCENT,
CR14R1V.T_ACW / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_ACW_UTIL_PERCENT,
V.T_HOLD / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_HOLD_UTIL_PERCENT,
V.T_OUTBOUND / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_OUTBOUND_UTIL_PERCENT,
(SUM (CR14R1V.T_TRAINING + CR14R1V.T_PERSONAL + CR14R1V.T_EMAIL + CR14R1V.T_COACHING + CR14R1V.T_AUTHORISED +
CR14R1V.T_MEETING + CR14R1V.T_ADMIN + CR60V.T_WITHCUSTOMER)) / (V.T_LOGIN - (CR14R1V.T_BREAK + CR14R1V.T_LUNCH)) AS TOTAL_AUX_UTIL_PERCENT,
SUM ((((V.T_TALK / 60) / 60) / 5.4) + (((V.T_WAIT / 60) / 60) / 5.4) + (((V.T_HOLD / 60) / 60) / 5.4)) AS STAFF_TIME_AVAIL_FTE
FROM ((DATAMART01.O_CR60_AG_DAY CR60O INNER JOIN DATAMART01.V_CR60_AG_DAY CR60V ON CR60O.OBJECT_ID = CR60V.OBJECT_ID)
INNER JOIN DATAMART01.T_CR60_AG_DAY CR60T ON CR60V.TIME_KEY = CR60T.TIME_KEY)
INNER JOIN (((DATAMART01.O_GROFAGS_DAY O INNER JOIN DATAMART01.V_GROFAGS_DAY V ON O.OBJECT_ID = V.OBJECT_ID)
INNER JOIN DATAMART01.T_GROFAGS_DAY T ON V.TIME_KEY = T.TIME_KEY)
INNER JOIN ((DATAMART01.O_CR14R1_AG_DAY CR14R1O
INNER JOIN DATAMART01.V_CR14R1_AG_DAY CR14R1V ON CR14R1O.OBJECT_ID = CR14R1V.OBJECT_ID)
INNER JOIN DATAMART01.T_CR14R1_AG_DAY CR14R1T ON CR14R1V.TIME_KEY = CR14R1T.TIME_KEY)
ON (T.TIME_KEY = CR14R1T.TIME_KEY) AND (V.OBJECT_ID = CR14R1V.OBJECT_ID))
ON (CR60T.TIME_KEY = T.TIME_KEY) AND (CR60V.OBJECT_ID = V.OBJECT_ID)
WHERE (((O.OBJECT_NAME)='ALL_AG_SHOP') AND ((T.DATE_YYYYMMDD)='20080203'));