PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

A.

B.

C.

D.

10 Comments on “Which Transact-SQL statement should you run?

  1. scotrideff says:

    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




    4



    4
  2. overkill says:

    Count(col) is counting over one column. returns 0 if the column hasn’t values

    Count(*) is counting over all columns of a row. returns a value greater than 0 if there are rows (regardless of null values in its columns)

    to count how many rows have value in one column Count(col) is the way

    if you want to count if how many rows there are than Count(*) is the way




    7



    0

Leave a Reply