Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to calculate master/detail table discount as value

$
0
0

hi

I have a master table columns like InvoiceID,InvoiceDate,Discount%,InvoiceTotal & detail table columns like ProductID,Qty,Price,Discount%,ExtendedPrice. Now I want to calculate both discount percentage as value in amount. I have the following query

SELECT     InvoiceID, SUM(CONVERT(money, (Price * Qty) * (1 - Discount) / 100) * 100) AS ExtendedPrice
FROM         dbo.[InvoiceDetail]
GROUP BY InvoiceID
which is just subtract detail discount only from ExtendedPrice but I want to Subtract both discount from the totalInvoiceAmount in order to get netSalesValue.

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>