Full-stack dev quiz question #5

Full-stack dev quiz question #5

quizThe fifth question in the quiz for a full-stack developer checks basic knowledge of SQL.

Correct answer for the fourth question is published.

 

 

Analyze the following SQL script created for SQL Server:

create table COUNTRIES (
   Ctr_Id int,
   Ctr_Name varchar(255)
)
GO

create table USERS (
   Usr_Id int,
   Usr_Ctr_Id int,
   Usr_Name varchar(255)
)
GO

insert into COUNTRIES (Ctr_Id, Ctr_Name)
values (1, 'Poland'), (2, 'Germany'), (3, 'India'), (4, 'Canada')

insert into USERS (Usr_Id, Usr_Ctr_Id, Usr_Name)
values (1, 2, 'Johannes'), (2, 2, 'Aldona'), (3, 3, 'Rahit')

What is the result of this query:

select Ctr_Name, count(1)
from COUNTRIES
        left join USERS on Ctr_Id = Usr_Ctr_Id
group by Ctr_Name
order by Ctr_Name

Choose one:

  1. Canada 1
    Germany 2
    India 1
    Poland 1
  2. Germany 2
    India 1
    Poland 0
    Canada 0
  3. Canada 0
    Germany 2
    India 1
    Poland 0
  4. Germany 2
    India 1
  5. Germany 2
    India 1
    null 0
    null 0

For the answer scroll down

.

.

.

 

 

 

 

 

 

 

 

 

 

.

.

.

The correct answer is a.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.