Oracle GROUP BY

The Oracle GROUP BY clause groups a select result into subsets that have matching values for one or more columns.

Oracle GROUP BY example

Select id, product, avg(amount), 
sum(amount), max(amount), count(*)
From sales  
Group By id, product
Order By id ;

Select count(name)
From customers  
Group By city
Order By count(customer_id);

Select
Case 
When price between 100 and 200 
	then 'Price Low: 100-200'
When price between 201 and 300 
	then 'Price High: 201-300'
Else 'Price Very High'
End
As test,
count(*) num_prices
Group By 
Case 
When price between 100 and 200 
	then 'Price Low: 100-200'
When price between 201 and 300 
	then 'Price High: 201-300'
Else 'Price Very High'
End