Grouping attributes may not be present in SELECT statement

It is normal if some or all grouping attributes will not be present in SELECT statement. The grouping will work anyway. SELECT statement is for presentation, while actual grouping is done by GROUP BY.

An example below demonstrated a typical case for usage SELECT attributes and GROUP BY attributes. Both department_id and job_id are present in SELECT and GROUP BY clauses.

But, if you remove those attributes from SELECT statement, it will work and produce same results for COUNT(*) column, just first two columns won’t be shown

you can even leave just one attribute in SELECT statement, while still having two in GROUP BY ( see below)

This knowledge is heavily tested on the exam



Leave a comment

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