Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Table_Item
-----------------------				

ItemId	ItemDescription	      SalePrice 	PurchasePrice	StockAvailable
1	Biscuit half Role	20                   17        	     45
2 	Lays Chips	        30	             25	             35
3	Soap Lux	        25	             22	             40



Table_ItemSoldDetail
--------------------------------		

ItemId	Invoice#    QtySold
1	   1	      1
2	   2	      1
1	   2	      2
1	   4	      1
2	   5	      3
3	   6	      1


and I want to show this result from above two tables

Item Sold with Count
-------------------------	
Item Description	Total Qty Sold
Biscuit half Role	   4
Lays Chips	           4
Soap Lux	           1


Please guide me what will be SQL query to generate this result ????


Thanks
Posted
Updated 22-Feb-14 5:50am
v3
Comments
CHill60 22-Feb-14 12:03pm    
What have you tried and where are you stuck?

1 solution

Try:
SQL
SELECT i.ItemDescriptin, SUM(isd.QtySold) FROM Table_ItemSoldDetail isd
JOIN Table_Items i
ON i.Id = isd.ItemId
GROUP BY isd.ItemId, i.ItemDescription


[edit]Typo in column name - OrignalGriff[/edit]
 
Share this answer
 
v2
Comments
DoingWork 22-Feb-14 12:29pm    
Many Thanksssssssssssssss
OriginalGriff 22-Feb-14 12:42pm    
You're welcome!

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