0

hi guys,

i had an account on Daniweb but forgot password and recovery was a bit hectic so decided to crreate a new account. the previous username was emma etigu.

i have a problem and need some help. below i have two tables from my dataset, i would like to write an sql statement that will give me TOTAL SALES for the two tables combined. the tables contain related data derived from two different transaction processes.

receipDetals customerReceiptDetails
itemnumber itemnumber
itemname itemname
itemcount itemcount
purchaseprice purchaseprice
retailprice retailprice

these are two different tables, receiptDetails and customerReceiptDetails. i would like total quantity then total sales.
thanks.

3
Contributors
3
Replies
23
Views
2 Years
Discussion Span
Last Post by moshelilin
0

I don't see any quantity or sales columns :(

What database is this coming from?

Do you want the SQL to populate your dataset in the first place, or are you wanting to sum things after the data is in a .net DataSet?

0

hi,

table1
itemName
itemCount
retailPrice
purchasePrice

table2
itemName
itemCount
retailPrice
purchasePrice

i would like to get combined total sales for both tables.

thanks.

0
SELECT SUM(cost) FROM
    (SELECT itemCount*purchasePrice as cost FROM table1
UNION ALL
    SELECT itemCount*purchasePrice as cost FROM table2)

Edited by Reverend Jim: Corrected code formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.