SQLTeam.com | Weblogs | Forums

Join


#1

Hi All,

Please let me know how to convert this query with Join. I want to display all the name from userlist and there sum from Input_Per table. If value is not available in Input_Per system will display 0 in Col A

Select a.UserId,b.Emp_Name,sum(b.a) as A from UserList a,Input_Per b
Where a.UserId*=b.userid
Group by a.UserId,b.Emp_Name


#2
SELECT a.UserId,
	b.Emp_Name,
	sum(b.a) AS A
FROM UserList a
LEFT JOIN Input_Per b
	ON a.UserId = b.userid
GROUP BY a.UserId,
	b.Emp_Name