Syntax

SQL Group Rows Syntax

In SQL, group rows: aggregates rows per group — SELECT country, COUNT(*) FROM users GROUP BY country;

Quick Answer

Syntax
SELECT country, COUNT(*) FROM users GROUP BY country;
SQLSyntax

Group Rows

Code example
SELECT country, COUNT(*) FROM users GROUP BY country;

Aggregates rows per group.

Learn More

How to group rows in SQL

  1. Open your SQL file or editor.
  2. Copy the example, then replace its sample names and values for your code.

SQL Group Rows Syntax

Use SELECT country, COUNT(*) FROM users GROUP BY country;.

Related Syntax References

Frequently asked questions

What is the SQL syntax for group rows?

Use this pattern: SELECT country, COUNT(*) FROM users GROUP BY country;

Can I copy this SQL code example?

Yes. Use Copy code and adapt the example to your program.

Is this SQL syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify