Link to home
Create AccountLog in
Avatar of ginsonic
ginsonicFlag for Romania

asked on

SQL .. SUM .. SUBSQL ?

I have next table structure:

Name product   ...   buy/sale ... quantity

Cats ....   1 ( I buy ) ...  10
Dogs ...   1  ...              20
Birds ...   1 ...               14
Cats ....  -1 ( I sell )  ...   5
Dogs ...  -1...                  7
Cats ...    1 ...               12

I need a sql that will return me:

Cats ...  17
Dogs ... 13
Birds ... 14

Can help me with a SQL script, please ?
ASKER CERTIFIED SOLUTION
Avatar of dduser
dduser

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of ginsonic

ASKER

Thanks for fast anwser. Was so easier that I'm feel so stupid because I don't thinked myself.

Thanks very much for support!