I need some help with a sql query, I was able to create the selection query but I am not sure how to subtract and multiply in T-SQL.
SELECT arInvoicedetail.Code, arInvoicedetail.Description, arInvoicedetail.Product, arInvoicedetail.Unit, arInvoicedetail.Qty, arInvoicedetail.Mass, arInvoicedetail.Tare, arInvoicedetail.Price, arInvoicedetail.Reason
FROM arInvoicedetail INNER JOIN
arInvoiceheader ON arInvoicedetail.InvoiceNumber = arInvoiceheader.InvoiceNumber
WHERE (arInvoiceheader.Datum >= CONVERT(DATETIME, '2013-02-20 00:00:29.000', 102)) AND (arInvoiceheader.Datum <= CONVERT(DATETIME, '2013-02-25 00:00:00', 102))
I need to subtract all items with a code 3 from code 1 where the product field is the same. Then I have to multiply price with mass where the unit is 0 and multiply qty with price where the unit is 1.