W
WendyUK
I am trying to age transactions into 30 days, 60 days etc and have put
together the following script but is giving a syntax error on "AS" on the 2nd
SUM line, can anyone please help me.
SELECT
PLSupplierAccountID, GoodsValueInAccountCurrency, TransactionDate,
DATEDIFF(DAY, TransactionDate, GETDATE()) AS no_of_days_since,
SUM(GoodsValueInAccountCurrency) AS THIRTY WHERE (no_of_days_since BETWEEN 1
AND 30)
AND
SUM(GoodsValueInAccountCurrency) AS SIXTY WHERE (no_of_days_since between 31
and 60)
AND
SUM(GoodsValueInAccountCurrency) AS NINETY WHERE (no_of_days_since between
61 and 90)
and
SUM(GoodsValueInAccountCurrency) AS MORE WHERE (no_of_days_since > 90)
FROM PLPostedSupplierTran
GROUP by PLSupplierAccountID, TransactionDate, GoodsValueInAccountCurrency
together the following script but is giving a syntax error on "AS" on the 2nd
SUM line, can anyone please help me.
SELECT
PLSupplierAccountID, GoodsValueInAccountCurrency, TransactionDate,
DATEDIFF(DAY, TransactionDate, GETDATE()) AS no_of_days_since,
SUM(GoodsValueInAccountCurrency) AS THIRTY WHERE (no_of_days_since BETWEEN 1
AND 30)
AND
SUM(GoodsValueInAccountCurrency) AS SIXTY WHERE (no_of_days_since between 31
and 60)
AND
SUM(GoodsValueInAccountCurrency) AS NINETY WHERE (no_of_days_since between
61 and 90)
and
SUM(GoodsValueInAccountCurrency) AS MORE WHERE (no_of_days_since > 90)
FROM PLPostedSupplierTran
GROUP by PLSupplierAccountID, TransactionDate, GoodsValueInAccountCurrency