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 |
leearenaa
Starting Member
3 Posts |
Posted - 2013-06-20 : 00:32:42
|
Hi there,How can I query two tables to get the list and number of total count? Below is my tables:User's Table:UserID | ProfessionID1234 | 13241 | 23435 | 1Profession's tableProfessionID | ProfessionName1 | Student2 | Chef3 | OthersSo how can I query that the output will be coming as below?ProfessionName | TotalCountStudent | 2Chef | 1Others | 0Thank you for the advance.LeeAreNaa |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-20 : 00:50:14
|
[code]SELECT p.ProfessionName,COUNT(UserID) AS TotalCountFROM Profession pLEFT JOIN User uON p.ProfessionID = u.ProfessionIDGROUP BY p.ProfessionName[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
leearenaa
Starting Member
3 Posts |
Posted - 2013-06-20 : 01:55:37
|
Its look great...Thank you..quote: Originally posted by visakh16
SELECT p.ProfessionName,COUNT(UserID) AS TotalCountFROM Profession pLEFT JOIN User uON p.ProfessionID = u.ProfessionIDGROUP BY p.ProfessionName ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
LeeAreNaa |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-20 : 02:00:56
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|