I don't understand using of group by | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I don't understand using of group by

9th Feb 2016, 7:12 AM
Meri
Meri - avatar
2 Answers
+ 12
It simply groups the table by the chosen column. Useful info yes? =) Like: [NAMES] [NUMS] Burak 18 Ally 7 Gina 99 Ally 3 Burak 3 Gina 2 *-------------------------* Select names,nums From exampletable Group By names; *-------------------------* [NAMES] [NUMS] Ally 7 Ally 3 Burak 18 Burak 3 Gina 99 Gina 2 And if you add an aggregate function, it becomes more handy: *-------------------------* Select names,sum(nums) From exampletable Group By names; *-------------------------* [NAMES] [NUMS] Ally 10 Burak 21 Gina 101 Because in a larger table with more columns, it becomes more important that you have the totals for the right column. For example: if you also add the city column, you could also group by city to see the totals for each city, instead of seeing the totals for names.
6th Oct 2016, 12:42 PM
Christine Fleming (PyGirl)
Christine Fleming (PyGirl) - avatar
+ 5
Group By is used when using aggregate function. See it as, if you wanna aggregate something, you should be doing it on the basis of something. Like if you want to find the sum of 12 months of salary of each employee, you'll sum(salary) ... group by (employee id) I hope this helps.
27th Feb 2016, 9:55 PM
Preeti Yadav
Preeti Yadav - avatar