Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
required single records from 2 tables for each itemname



	ALTER view [dbo].[Inventorymgmt] AS 
SELECT distinct   
T0.ItemName,T0.Qty,T1.Qty as '	usedqty'
FROM [dbo].[MaterialIO] as T0
INNER JOIN [dbo].[MaterialOutuse] as T1 on
	T0.itemname=t1.itemname
	group by T0.Qty,t1.Qty,T0.ItemName



ItemName	Qty		usedqty
ACID	10	0
ACID	10	5
ACID	20	0
ACID	20	5
BRASS	50	20


What I have tried:

I have added group of column still it shows double records. with distinct option
Posted
Updated 2-Feb-19 1:47am

1 solution

You need to use SUM() to sum the qty, see example here: SQL query with distinct and sum - Stack Overflow[^]
 
Share this answer
 
Comments
Master Vinu 3-Feb-19 5:49am    
thx rick

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