Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table 'txfile' with 4 columns namely CategoryId, ProductId,Qty,DespatchDate. Now, for a given DespatchDate, I want to find the total of column 'Qty' based on 'CategoryId' and
'ProductId'. Each 'CategoryId' will have one or more 'ProductId'. Can any one help me out how to use the select statement for my requirement?
Posted
Comments
Sibasisjena 8-Jan-14 1:29am    
Please have a look my solution. If this solution will not work then let me know.
Peter Leow 8-Jan-14 1:37am    
What output do you expect to have?

SQL
SELECT SUM(Qty) AS 'SUMQty' FROM  FROM txfile WHERE DespatchDate=GETDATE() GROUP BY CategoryId;

Place your date value in place of GETDATE()
 
Share this answer
 
SQL
Select sum(Qty) as 'SumQty' from txfile where DespatchDate="give despatch date" group by CategoryId,ProductId
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 8-Jan-14 1:49am    
Thanks. It solved my requirement.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900