Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Inner Join With Count And Case
WhatsApp
Gagan Gautam
8y
8.3
k
0
4
25
Blog
Here in this blog, I have discussed about inner join with count and case tutorial.
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
Output
SQL Server
Case
Inner Join
Up Next
Physical Join Vs Logical Join In SQL Server
Ebook Download
View all
Introducing Microsoft SQL Server 2016
Read by 11k people
Download Now!
Learn
View all
Membership not found