This is a draft cheat sheet. It is a work in progress and is not finished yet.
|
|
Rangfolge
SELECT [ DISTINCT | ALL ]
FROM Tabelle [AS Alias]
JOIN .. ON
[WHERE]
[ GROUP BY]
[HAVING]
[ UNION [ALL] ]
[ ORDER BY] |
ORDER BY
ASC (Standart) |
Aufsteigend |
DESC |
Absteigend |
|
ORDER BY plz DESC, name |
Mengenoperationen
UNION |
Vereinigung |
INTERSECT |
Duchschnitt -> Datensätze, die in beiden Mengen vorhanden sind |
EXEPT / Minus |
Differenz -> Alle die in Tabelle A, aber NICHT in Tabelle B vorhanden sind |
|
|
Aggregetfunktionen
COUNT(*) |
Anzahl |
SUM(*) |
Summe |
AVG(*) |
Durchschnitt |
MIN() / MAX() |
Minimum / Maximum |
VAR(*) |
Varianz |
STDEV(*) |
Standartabweichung |
WHERE
= < > <= => <> |
WHERE id > 3 |
BETWEEN |
WHERE id BETWEEN 40 AND 50 |
NOT BETWEEN |
WHERE ID NOT BETWEEN 40 AND 50 |
LIKE |
WHERE name LIKE 'B%' |
|
WHERE name LIKE '%alt%' |
|
WHERE name LIKE '_eier' |
ISNULL |
WHERE telefon IS NULL |
|
WHERE telefon IS NOT NULL |
IN |
WHERE farbe IN ('Grün','Gelb') |
|
WHERE farbe IN (SELECT ...) |
NOT |
WHERE NOT (id >100) |
AND |
WHERE id > 100 AND farbe = 'blau' |
OR |
WHERE id < 100 OR farbe='blau' |
XOR |
True, wenn genau ein Wert wahr und ein Wert falsch ist |
|