Using Temporary Table with DW Recordset Behavior
Is it possible to use SQL Temporary Tables when creating a recordset using the DW behavior? Any ideas would be greatly appreciated.
I have the following that works fine when entered used as straight SQL but It's not working when I enter it in the Advanced settings of the DW Recordset behavior:
CREATE TEMPORARY TABLE TEMP_LOGIN_COUNT AS (
SELECT
user.USER_NAME,
user.FIRST_NAME,
user.LAST_NAME,
user.EMAIL_ADDRESS,
sch.SCHOOL_ID,
sch.SCHOOL_ABBREV,
COUNT( history.DATETIME ) AS LOGIN_COUNT
FROM C_USER AS user
LEFT OUTER JOIN C_USER_LOGIN_HISTORY AS history
ON user.USER_NAME = history.USER_NAME
LEFT JOIN C_SCHOOL AS sch
ON user.SCHOOL_ID = sch.SCHOOL_ID
GROUP BY user.USER_NAME
);
SELECT
loginCount.USER_NAME,
loginCount.FIRST_NAME,
loginCount.LAST_NAME,
loginCount.EMAIL,
loginCount.SCHOOL_ID,
loginCount.SCHOOL_ABBREV,
loginCount.LOGIN_COUNT
FROM
TEMP_LOGIN_COUNT AS loginCount
LEFT JOIN USER_USER_TYPE AS type
ON loginCount.USER_NAME = type.USER_NAME
GROUP BY loginCount.USER_NAME
HAVING
SUM( type.USER_TYPE_ID ) =3
AND
COUNT( type.USER_TYPE_ID ) =1
ORDER BY loginCount.LAST_NAME, loginCount.FIRST_NAME;
