Inside Group by




Group by <SameColumn>,

this basically  group the rows having same column value.

lets say, --> Group by department,

this this will club all the rows which has same department, and it will have some sort of list of list,


1st position, list of 6 rows, from CSE department
2nd row,      list of 2 rows from ECE department


Now in these rows, you can only perform some aggregate funtion and display it, you can display employee name of department as output, because one collection, say 1st position, may have 6 rows each having different employee name, what it will display?

i.e. you should/can perfrom only agregate function on this grouped by list.




select count(CustomerID) as countryhead,country,city from customers group by Country,city order by countryhead DESC;


countryheadCountryCity
6UKLondon
5MexicoMéxico D.F.
4BrazilSão Paulo
3ArgentinaBuenos Aires
3BrazilRio de Janeiro
3SpainMadrid




Comments

Popular posts from this blog

Oracle User vs Oracle Schemas

Having and Where Clause