In this code I am showing how to count records in more than one table and how to use case for printing message.
- select COUNT( * ) as 'Num of Role', Types = (
- case when UserRole.Id = 1 then 'Created By Admin'
- when UserRole.Id = 8 then 'Created By Creator'
- end) from Model inner join dbo.[User] on Model.UserId = [User].Id
- inner join UserRole on dbo.[User].UserRoleId = dbo.[UserRole].Id Group By UserRole.Id

SubashPosted Jul 3, 2016, 4:05 AM
Nice
kalu singh raoPosted Jul 1, 2016, 3:14 PM
Nice...
Gagan SharmaPosted Jun 30, 2016, 7:57 AM
NIce