Hi everyone,
I'm trying to convert a mdb-query to adp-query (transSQL). Instead of IIF I now use CASE When. But it doesn't seem possible to reuse an alias. I created PrepaidAmount, which is calculated in the first line. Now I want to reuse this calculated field to do a second calculation, but this produces an ADO error message: 'Invalid column name PrepaidAmountANG'. How do I 'reuse' a calculated field in this query?
Pampers![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
Just let it go...
I'm trying to convert a mdb-query to adp-query (transSQL). Instead of IIF I now use CASE When. But it doesn't seem possible to reuse an alias. I created PrepaidAmount, which is calculated in the first line. Now I want to reuse this calculated field to do a second calculation, but this produces an ADO error message: 'Invalid column name PrepaidAmountANG'. How do I 'reuse' a calculated field in this query?
Code:
SELECT CASE WHEN [Collect/Prepaid] = 1 THEN [rate] * [qtyPer] END AS PrepaidAmount,
CASE WHEN [Collect/Prepaid] = 0 THEN [rate] * [qtyPer] END AS CollectAmount,
CASE WHEN [currency] = 'USD' THEN PrepaidAmount * 1.82 END AS PrepaidANG
FROM dbo.tblChargeBolImp
Pampers
![[afro] [afro] [afro]](/data/assets/smilies/afro.gif)
Just let it go...