Podzapytania skorelowane - Przykłady

select * from tabela1 e
where
kolumna1 > (select avg(kolumna1) from tabela1
where kolumna1 = e.kolumna1)

select
kolumna1,
(select kolumna2 from tabela1 where kolumna3 = e.kolumna3) e
from tabela2 e

select
kolumna1
from tabela1 e
where
exists (select * from tabela2
where kolumna2 = e.kolumna2)

select
kolumna1
from tabela1 e
where
not exists (select * from tabela2
where kolumna2 = e.kolumna2)

Tags: