Hoofdstuk 8: select enzo
Select: welke kolommen (bv klantID)
o Distinct: alle rijen uniek
o Aliassen: bv tblKlant as klanten
From: welke tabel (bv tblKlant)
Where: voorwaarden (bv klantID = 54)
o (not) like bv klantNaam like ‘%anton%’
o Or, and, not bv klantNaam like ‘%anton%’ and klantID = 5
o (not) between x and y bv productnummer between 5 and 10
o (not) in bv productnummer in (1,3,5) 1, 3 of 5
o Is (not) null bv region is not null
Group by: groeperen van gegevens
o Having: groepje waar x=2
Order by: sorteren
o Bv porductname desc
Functies
Now() yyyy-mm-dd hh:mm:ss
Round, floor, ceiling, …
Case
o When price is null then ‘yeet’
o When price <10 then ‘blabla’
o …
End
, Hoofdstuk 9: group by en joins
Functies
Sum(…)
Avg (…)
Min(…)
max(…)
count(…)
group by (eerst rijen filteren dan in de groep)
bv select categorie, count(productID) from producten where stock<5 group by categorie
per categorie het aantal producten waar de stock<5
having (eerst groep maken en dan de groepen filteren)
bv select categorie, count(productID) from producten group by categorie having
count(productID) >10
per categorie die >10 producten bevat het aantal producten
joins
zie samenvatting
inner
left / right / full outer
union
select name, city, postcode from employees
union
select companyname, city, postcode from customers
Select: welke kolommen (bv klantID)
o Distinct: alle rijen uniek
o Aliassen: bv tblKlant as klanten
From: welke tabel (bv tblKlant)
Where: voorwaarden (bv klantID = 54)
o (not) like bv klantNaam like ‘%anton%’
o Or, and, not bv klantNaam like ‘%anton%’ and klantID = 5
o (not) between x and y bv productnummer between 5 and 10
o (not) in bv productnummer in (1,3,5) 1, 3 of 5
o Is (not) null bv region is not null
Group by: groeperen van gegevens
o Having: groepje waar x=2
Order by: sorteren
o Bv porductname desc
Functies
Now() yyyy-mm-dd hh:mm:ss
Round, floor, ceiling, …
Case
o When price is null then ‘yeet’
o When price <10 then ‘blabla’
o …
End
, Hoofdstuk 9: group by en joins
Functies
Sum(…)
Avg (…)
Min(…)
max(…)
count(…)
group by (eerst rijen filteren dan in de groep)
bv select categorie, count(productID) from producten where stock<5 group by categorie
per categorie het aantal producten waar de stock<5
having (eerst groep maken en dan de groepen filteren)
bv select categorie, count(productID) from producten group by categorie having
count(productID) >10
per categorie die >10 producten bevat het aantal producten
joins
zie samenvatting
inner
left / right / full outer
union
select name, city, postcode from employees
union
select companyname, city, postcode from customers