Full-stack dev quiz question #5
The 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)
left join USERS on Ctr_Id = Usr_Ctr_Id
group by Ctr_Name
order by Ctr_Name
Canada 1 Germany 2 India 1 Poland 1
Germany 2 India 1 Poland 0 Canada 0
Canada 0 Germany 2 India 1 Poland 0
Germany 2 India 1
Germany 2 India 1 null 0 null 0
For the answer scroll down
The correct answer is a.