Writing SQL

GROUP BY With Joins

Combining inner joins with GROUP BY and ORDER BY, and grouping with or without aggregates.

Can we use GROUP BY without aggregation?

Yes, you can use GROUP BY without an aggregate function. It returns each distinct value once, much like DISTINCT, and shows where MySQL raises an error.

2 min read

How to write an inner join query in SQL?

An inner join query uses INNER JOIN and an ON condition to return only rows that match in both tables, with the syntax, an example and common mistakes.

2 min read

Which goes first, GROUP BY or ORDER BY?

GROUP BY runs before ORDER BY in SQL. Here is the order SQL processes clauses in, with a sales example that groups totals and then sorts them.

2 min read

Related topics

More in writing sql