Hello,
The following code populates a field named PREV_MONTH with the values in EFFECTIVE_DATE using DateAdd to extract previous month's value. The resultset returns the records exactly as I anticipated, however, about three seconds later, an error message appers reading "At most one record can be returned by this subquery", at which point all fields turn to 'ERROR'.
Do I need to change the subquery to allow for aggregate output? Thank you.......
SELECT e1.EFFECTIVE_DATE, e1.VALUE, e1.TOTAL_TXN_AMT, (SELECT TOTAL_TXN_AMT
FROM AL_EVNT_HEADER e2
WHERE e2.EFFECTIVE_DATE=format(DateAdd("m", -1, e1.EFFECTIVE_DATE), "YYYY-MM-DD") AND e2.VALUE=e1.VALUE) AS PREV_MONTH
FROM AL_EVNT_HEADER AS e1
WHERE (((e1.ACTION)="SEGMENT"))
ORDER BY e1.VALUE;
The following code populates a field named PREV_MONTH with the values in EFFECTIVE_DATE using DateAdd to extract previous month's value. The resultset returns the records exactly as I anticipated, however, about three seconds later, an error message appers reading "At most one record can be returned by this subquery", at which point all fields turn to 'ERROR'.
Do I need to change the subquery to allow for aggregate output? Thank you.......
SELECT e1.EFFECTIVE_DATE, e1.VALUE, e1.TOTAL_TXN_AMT, (SELECT TOTAL_TXN_AMT
FROM AL_EVNT_HEADER e2
WHERE e2.EFFECTIVE_DATE=format(DateAdd("m", -1, e1.EFFECTIVE_DATE), "YYYY-MM-DD") AND e2.VALUE=e1.VALUE) AS PREV_MONTH
FROM AL_EVNT_HEADER AS e1
WHERE (((e1.ACTION)="SEGMENT"))
ORDER BY e1.VALUE;