question

SHAHGEE avatar image
SHAHGEE asked

SQL Query for Substraction

i have two columns source_id and Qty in one table TRANS. Source_id 2002 Qty 100 , 200 , 500 , -500 i want to get balance of this source_id which is 100+200=300 because (-500+500=0) how can i write a query for this and can i show 100 and 200 saparate in two lines as balance
sql-server-2008
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Wimbush avatar image David Wimbush commented ·
It's not clear what you want the result to look like or what the rules are. If you just want the total you can use the sum() function. But it sounds like you want something more complex. Please explain more.
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.