SQL DISTINCT, ORDER BY, COUNT – Quiz

For each question below, select the best answer. To select the best answer, click on the circle located on the left of this answer. When all questions are answered, click on the Submit button

Question 1

Consider the following query: select distinct first_name from clients. The following clients are in this table: Aamir Rao, Aamir Malhotra, Ankur Gopal. The query will return how many rows:

1
2
3
it depends

Question 2

Consider the following query: select distinct first_name,last_name from clients. The following clients are in this table: Aamir Rao, Aamir Malhotra, Ankur Gopal, Aamir Malhotra (two clients have the exact same name). The query will return how many rows:

1
2
3
4

Question 3

Consider the following query: select count(*) from clients. The following clients are in this table: Aamir Rao, Aamir Malhotra, Ankur Gopal, Aamir Malhotra (two clients have the exact same name). The query will return which result:

Aamir Rao, Aamir Malhotra, Ankur Gopal, Aamir Malhotra
Aamir, Ankur
4
3
2

Question 4

Consider the following query: select count(distinct first_name) from clients. The following clients are in this table: Aamir Rao, Aamir Malhotra, Ankur Gopal, Aamir Malhotra (two clients have the exact same name). The query will return which result:

Aamir, Ankur
Aamir Rao, Aamir Malhotra, Ankur Gopal
3
2
4

Question 5

I want the client Aamir Rao to appear on top of client Aamir Gopal and Ankur Gopal appear on top of Aamir Rao. Which query will do that :

select * from clients order by first_name,last_name asc
select * from clients order by first_name,last_name desc
select * from clients order by first_name desc
select * from clients order by first_name asc
none of the above

Question 6

I want the client Aamir Rao to appear below client Aamir Gopal and Ankur Gopal appear below Aamir Rao . Which query will do that (select the best answer):

select * from clients order by first_name,last_name
select * from clients order by first_name,last_name desc
select * from clients order by first_name desc
select * from clients order by first_name asc
none of the above

 

 

Once you have completed the quiz, calculated your score and reviewed your answers, I invite you to go to the next lesson about the SQL where condition.
 
Share on:

Something not clear? Ask your question here:

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
 

Author:
Last udpated: September 10, 2017
Created: September 20, 2014