PostgreSQL Column must appear in the GROUP BY clause

Column must appear in the GROUP BY clause or be used in an aggregate function

GROUP BY clause

The cause of error: Column must appear in the GROUP BY clause or be used in an aggregate function
The solution is to add the GROUP BY clause with column used in the select.

Wrong query

select first_name, last_name, count(*) 
from test.students;

ERROR: column “students.first_name” must appear
in the GROUP BY clause or be used in an aggregate function
LINE 1: select first_name, last_name, count(*)

Query returned successfully in 421 msec.

Correct query

select first_name, last_name, count(*) 
from test.students 
group by first_name, last_name;