Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 add in a query

Author  Topic 

fm88
Starting Member

18 Posts

Posted - 2008-05-19 : 07:15:09
I have a table tblInventory with a "Category" field and "quantity".
I want a query where I can select all the records with a given subcategory and sum the quantities.
for example,if i have 2 records with "Cat1" and quantities 5 and 10,
The result of the query should be 15.
Help!!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-19 : 07:19:43
SELECT Category, SUM(Quantity)
FROM tblInventory
GROUP BY Category



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-19 : 07:20:55
hi
pls try this

select category,sum(quantity) as quantity_sum from tblInventory
group by category

ok tanx..
Go to Top of Page
   

- Advertisement -