GROUP BY i HAVING BY - Przykłady

select
kolumna1,
count(*)
from tabela1
group by
kolumna1

select
kolumna1,
kolumna2,
count(*)
from tabela1
group by
kolumna1,
kolumna2
order by kolumna1

select
kolumna1,
count(*)
from tabela1
group by
kolumna1
having
count(*) > 10

select
kolumna1,
kolumna2,
count(*)
from tabela1
group by
kolumna1,
kolumna2
having
count(*) > 10
order by
kolumna1

select
kolumna1,
count(*)
from tabela1
where
kolumna1 > 20
group by
kolumna1
order by kolumna1

Tags: