You have a database named MyDb. You run the following Transact-SQL statements:
A value of 1 in the IsActive column indicates that a user is active.
You need to create a count for active users in each role. If a role has no active users. You must display a zero
as the active users count.
Which Transact-SQL statement should you run?
wrong answer is n
Select
R.Rolename,
count(userID) as activeUsercount
from tblRoles R
Left join (select userID, RoleId from tblUsers Where Isactive = 1) u
On u.roleID = R.roleID
Group by R.roleID,R.rolename
Answer A is correct (see also question 4).
Agree
Agree with Peter.
Answer A is correct.
Hello Peter and E Rod,
I take your point, but how can a Count(*) give 0 back as result?
how is any answer correct as they dont cater to display zero?
my bad i see the bit data type now
Sample T-SQL script is here
https://1drv.ms/u/s!AqGoN4F5XgKMj45pg2yhZkknVsJkxg