Which Transact-SQL statement should you run?

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?

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?

A.

B.

C.

D.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


scotrideff

scotrideff

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

Peter

Peter

Answer A is correct (see also question 4).

E Rod

E Rod

Agree with Peter.
Answer A is correct.

Jens K.

Jens K.

Hello Peter and E Rod,

I take your point, but how can a Count(*) give 0 back as result?

mo

mo

how is any answer correct as they dont cater to display zero?

mo

mo

my bad i see the bit data type now