MySQL Questions and Answers – The group by & having Clause

This set of MySQL Multiple Choice Questions & Answers (MCQs) focuses on “The group by & having Clause”.

1. What is the meaning of “GROUP BY” clause in Mysql?
a) Group data by column values
b) Group data by row values
c) Group data by column and row values
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

2. Which clause is similar to “HAVING” clause in Mysql?
a) SELECT
b) WHERE
c) FROM
d) None of the mentioned
View Answer

Answer: b
Explanation: “WHERE” is also used to filter the row values in Mysql.

3. What is the meaning of “HAVING” clause in Mysql?
a) To filter out the row values
b) To filter out the column values
c) To filter out the row and column values
d) None of the mentioned
View Answer

Answer: a
Explanation: None.
advertisement
advertisement

4. “COUNT” keyword belongs to which categories in Mysql?
a) Aggregate functions
b) Operators
c) Clauses
d) All of the mentioned
View Answer

Answer: a
Explanation: None.

5. Which among the following belongs to an “aggregate function”?
a) COUNT
b) UPPER
c) LOWER
d) All of the mentioned
View Answer

Answer: a
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Which of the following belongs to an “aggregate function”?
a) COUNT
b) SUM/AVG
c) MIN/MAX
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

7. Which clause is used with an “aggregate functions”?
a) GROUP BY
b) SELECT
c) WHERE
d) Both GROUP BY and WHERE
View Answer

Answer: a
Explanation: “GROUP BY” is used with aggregate functions.
advertisement

8. What is the significance of the statement “GROUP BY d.name” in the following MySQL statement?

SELECT d.name, COUNT (emp_id) emp_no
FROM department d INNER JOIN Employee e
ON d.dept_id=e.emp_id
GROUP BY d.name

a) Aggregation of the field “name” of both table
b) Aggregation of the field “name” of table “department”
c) Sorting of the field “name”
d) None of the mentioned
View Answer

Answer: b
Explanation: “GROUP BY” clause s used for aggregation of field.
advertisement

9. What is the significance of the statement “HAVING COUNT (emp_id)>2” in the following MySQL statement?

SELECT d.name, COUNT (emp_id) emp_no
FROM department d INNER JOIN Employee e
ON d.dept_id=e.emp_id
GROUP BY d.name
HAVING COUNT (emp_id)>2

a) Filter out all rows whose total emp_id below 2
b) Selecting those rows whose total emp_id>2
c) Filter out all rows whose total emp_id below 2 & Selecting those rows whose total emp_id>2
d) None of the mentioned
View Answer

Answer: c
Explanation: “HAVING” clause are worked similar as “WHERE” clause.

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.