Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

how to get this result?

$
0
0
Table1
Code:

Product    quanity
A              50
B              22
D              11
C              31
B              43
D              8
C              13
A              43

1- How can we get the following table/query from the about table. As you see the sum of each item is shown.
Query1
Code:

Product        quantity_sum
A                    93
B                    65
C                    44
D                    19

2- Imagine, that because of any reason, the sum of the quantities of each item should be deducted from item D. can we get the following table/query?
Query 2
Code:

Product    quantitysum  D-deduction    result
A              93            19            74
B              65            19            46
C              44            19            25

Thank you

Viewing all articles
Browse latest Browse all 13329

Trending Articles