I am just confused with the execution sequence of a SQL query when we use GROUP BY and HAVING with a WHERE clause. Which one gets executed first? What is the sequence?
GROUP BY
HAVING
WHERE
in order:
FROM & JOINs determine & filter rows WHERE more filters on the rows GROUP BY combines those rows into groups HAVING filters groups ORDER BY arranges the remaining rows/groups LIMIT filters on the remaining rows/groups
1.4m articles
1.4m replys
5 comments
57.0k users