SQL GROUP BY – 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

We have 3 lines per state in a table. There are 4 states in the table. If we group by state, we will see in the results (choose the best answer):
3 lines.
3 lines multiplied by the number of states.
12 lines.
as many lines that there are states.

Question 2

Consider the fragment “count(*) from sales group by state”. Which of the following statement is the true:
the query will return the number of states.
the query will return the number of rows per state.

Question 3

Consider the fragment “having sum(revenue)>3000”. What can happen with the group having the following revenues : 1000, 50, 5:
It can show the name of the group followed by 3.
It can show the name of the group followed by 1055.
It will not show up.

Question 4

Consider the query: “select state,count(*),sum(revenue) from sales where revenue>200 group by state having sum(revenue)>300”. What can not happen with the group having the following revenues : 100, 500,200:
The result line corresponding to this group contains the number 1.
The result line corresponding to this group contains the number 500.
The result line corresponding to this group contains the number 800.

Question 5

Consider the fragment “having sum(revenue)>300”. What can happen with the group having the following revenues : 500, 300,400:
We display no line for this group.
We show the name of the group followed by “Karnataka”.

 

 

Once you have completed the quiz, calculated your score and reviewed your answers, I invite you to go to the next chapter about modifying data with SQL.
 
Share on:


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