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.
Author |
Topic |
alastairc
Starting Member
1 Post |
Posted - 2012-09-30 : 20:14:47
|
Hi team,This query has me stumped.It should be easy, but i can't get it. The null line (ie when there is no match) is the tough bit. Forgive me for my simple query!Table 1: AppointmentsTYPERegularRegularRegularMerchTable 2: PlansTYPE RegularMerchSpecialResult NeededTYPE COUNTRegular 3Merch 1Special 0 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-30 : 21:45:56
|
Use a LEFT OUTER JOIN, like shown below:SELECT a.[Type], COUNT(b.[type]) AS [Count]FROM Plans a LEFT JOIN Appointments b ON a.[type] = b.[type]GROUP BY a.[type] |
|
|
|
|
|