Skip to content
Advertisement

How to use group by in sql? (I need sequelize)

I have

But it fails with this error:

Works fine without GROUP BY

Advertisement

Answer

The GROUP BY statement groups rows that have the same values into summary rows, in your case, it is the country_code.

It is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.

That means, for expl : you want to count how many company_number per country_code

So, what you can do is :

Hope this helps 😉

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement