Operating in an Excel query, I need a conditional statement that will read one field, and based on that value, set another field to a minus (or not).
My SQl code is as follows:
SELECT "_bvSTTransactionsFull".txdate,
SUM("_bvSTTransactionsFull".debit) AS 'TOTALDebit',
SUM("_bvSTTransactionsFull".credit) AS 'TOTALCredit',
SUM("_bvSTTransactionsFull".tax_amount) AS 'TOTALTax_Amount',
SUM("_bvSTTransactionsFull".VALUE) AS 'TOTALValue',
SUM("_bvSTTransactionsFull".actualvalue) AS 'TOTALActualValue',
SUM("_bvSTTransactionsFull".actualsalesvalue) AS 'TOTALActualSalesValue',
SUM("_bvSTTransactionsFull".profit) AS 'TOTALProfit'
FROM sqlschema.dbo."_bvSTTransactionsFull" "_bvSTTransactionsFull"
WHERE ( "_bvSTTransactionsFull".txdate >=?
AND "_bvSTTransactionsFull".txdate <=? )
GROUP BY "_bvSTTransactionsFull".txdate,
"_bvSTTransactionsFull".description
HAVING ( "_bvSTTransactionsFull".description LIKE 'POS Sale' )
OR ( "_bvSTTransactionsFull".description LIKE 'POS Return' )
ORDER BY "_bvSTTransactionsFull".txdate
I need the select query to look at a field named "ActualQuantity
" (in the table "_bvSTTransactionsFull
") and if this field is <0 , then Tax_Amount = -(Tax_Amount)
, or if ActualQuantity >=0, then Tax_Amount = Tax_Amount
.
Please note the query is "summed", so I assume this conditional aspect needs to be handled before summation takes place. The query summates approximately 100 000 records into daily totals.