Does GROUP BY clause needs an aggregate function?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Does GROUP BY clause needs an aggregate function??

In MySQL I've seen "GROUP BY" work without any aggregate functions but the general syntax is quite different...... Can anyone please clear this contradiction??

21st Sep 2019, 1:23 AM
Aditya
Aditya - avatar
9 Answers
21st Sep 2019, 2:26 PM
Rustem Sharipov
Rustem Sharipov - avatar
+ 3
yup you're right buddy sorry for wasting your time 😊
21st Sep 2019, 4:17 PM
Aditya
Aditya - avatar
+ 2
Rustem Sharipov it won't work anywhere else other than mysql
21st Sep 2019, 6:14 AM
Aditya
Aditya - avatar
+ 1
It never worked in Postgres
21st Sep 2019, 1:49 PM
Aditya
Aditya - avatar
+ 1
thanks Shin one Chan sort of a famous cartoon character 🤣
11th Dec 2019, 1:12 AM
Aditya
Aditya - avatar
0
Aggregate functions can be omitted. E.g.instead of: Select customer,Sum(sales) Group by customer we can just run: Select customer Group by customer
21st Sep 2019, 4:05 AM
Rustem Sharipov
Rustem Sharipov - avatar
0
NULL_ptr It works. At least in MySQL, in SQL Server and in PostgreSQL.
21st Sep 2019, 1:43 PM
Rustem Sharipov
Rustem Sharipov - avatar
0
NULL_ptr no problema frd!
21st Sep 2019, 4:18 PM
Rustem Sharipov
Rustem Sharipov - avatar
0
It's works. The result will be the same as if use DISTINCT clause with the same columns but usually GROUP BY is faster.
10th Dec 2019, 5:07 PM
Shin
Shin - avatar