how to substract two sums based on different field values in one table (view)

Posted by user1749640 on Stack Overflow See other posts from Stack Overflow or by user1749640
Published on 2012-10-16T10:48:18Z Indexed on 2012/10/17 5:02 UTC
Read the original article Hit count: 108

Filed under:
|
|

example: i need the numbers of which the sum of the amount where id = 1 is not equal of the sum of the amount where id <> 1, together with the id's and difference.
The table (view in this case) may look like this:

NUMBER   AMOUNT   ID

0001     500       1
0001     500       2
0002     400       3
0003     299       1
0003     300       3
0003     300       3

Many thanks for your help on this one.

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql