SQL GROUP BYIT technician command center
Database · SQL and Database Administration

SQL GROUP BY

Aggregate rows by a column.

Copy-ready commandSQL GROUP BY
SELECT department, COUNT(*) FROM users GROUP BY department;

Requirements and permissions

Requirements
Appropriate database client and connection
Permissions
Database privileges vary
Last reviewed
2026-07-31

Examples

Basic example

Aggregate rows by a column.

SELECT department, COUNT(*) FROM users GROUP BY department;

Common errors

Command not found

Confirm Appropriate database client and connection is installed and available in your current shell.