1. Home
  2. Computer Science MCQs
  3. MySQL
  4. What does the GROUP BY clause do in a MySQL query?

Added 27 Jan 2024

What does the GROUP BY clause do in a MySQL query?

  1. Combine data from multiple tables.
  2. Sort the results of a query based on a specific column.
  3. Group rows together based on a shared value.  Correct answer
  4. Filter data based on a condition.

Correct answer

C. Group rows together based on a shared value. 

16 views

MCQSEXAM

Explanation

GROUP BY groups rows that share the same value in one or more columns into summary rows. It is almost always used with aggregate functions: SELECT city, COUNT(*) FROM users GROUP BY city; returns one row per city.

Sorting is done by ORDER BY, filtering rows by WHERE, and filtering groups by HAVING.

Practise more Database Management Systems MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More MySQL MCQs

Practise all MySQL MCQs

Similar MCQs