Link to home
Start Free TrialLog in
Avatar of grwallace
grwallace

asked on

SQL Add a total column

I have a table as follows

StockId                      Product                                                  Quant   Cancelled
381847      Dry King Scallops 4x2kg XXL Ecosse FAO27      30.0000       True
381845      Dry King Scallop 4x2kg -Ecosse FAO 27              40.0000       True
381845      Dry King Scallop 4x2kg -Ecosse FAO 27                5.0000       False
381845      Dry King Scallop 4x2kg -Ecosse FAO 27                7.0000       False
381847      Dry King Scallops 4x2kg XXL Ecosse FAO27        5.0000       False

I am looking to query this table and add another column for the total items for each stockId - e.g. for each row beginning 381847 it should be 5 if the query excludes cancelled lines or 35 if it includes them and for each line beginning 381845 it should be 12 or 52.

I could write a program to do this, but I think that it should be possible with a query.
Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of grwallace
grwallace

ASKER

That will do nicely - thank you