Zahlen filtern

SQL für Fortgeschrittene

Jasmin Ludolf

Data Science Content Developer, DataCamp

WHERE

  • WHERE Filterklausel

Bild mit einer Vielzahl von bunten Mänteln

SQL für Fortgeschrittene

WHERE

WHERE color = 'green'

Bild mit einer Vielzahl von bunten Mänteln und einem Kreis um den grünen Mantel

SQL für Fortgeschrittene

WHERE mit Vergleichsoperatoren

SELECT title
FROM films
WHERE release_year > 1960;
|title                |
|---------------------|
|Judgment at Nuremberg|
|Pocketful of Miracles|
|The Hustler          |
|The Misfits          |
...
SQL für Fortgeschrittene

Vergleichsoperatoren

SELECT title
FROM films
WHERE release_year < 1960;
|title                                          |
|-----------------------------------------------|
|Intolerance:Love's Struggle Throughout the Ages|
|Over the Hill to the Poorhouse                 |
|The Big Parade                                 |
|Metropolis                                     |
...
SQL für Fortgeschrittene

Vergleichsoperatoren

SELECT title
FROM films
WHERE release_year <= 1960;
|title                                          |
|-----------------------------------------------|
|Intolerance:Love's Struggle Throughout the Ages|
|Over the Hill to the Poorhouse                 |
|The Big Parade                                 |
|Metropolis                                     |
...
SQL für Fortgeschrittene

Vergleichsoperatoren

SELECT title
FROM films
WHERE release_year = 1960;
|title        |
|-------------|
|Elmer Gantry |
|Psycho       |
|The Apartment|
SQL für Fortgeschrittene

Vergleichsoperatoren

SELECT title
FROM films
WHERE release_year <> 1960;
|title                                          |
|-----------------------------------------------|
|Intolerance:Love's Struggle Throughout the Ages|
|Over the Hill to the Poorhouse                 |
|The Big Parade                                 |
|Metropolis                                     |
...
SQL für Fortgeschrittene

Vergleichsoperatoren

  • > Größer als oder nach
  • < Weniger als oder vor
  • = gleich
  • >= größer als oder gleich
  • <= kleiner als oder gleich
  • <> ungleich
SQL für Fortgeschrittene

WHERE mit Strings

  • Verwende einfache Anführungszeichen zum Filtern von Strings
SELECT title
FROM films
WHERE country = 'Japan';
|title            |
|-----------------|
|Seven Samurai    |
|Tora! Tora! Tora!|
|Akira            |
|Madadayo         |
|Street Fighter   |
...
SQL für Fortgeschrittene

Reihenfolge der Ausführung

-- Written code:
SELECT item
FROM coats
WHERE color = 'green'
LIMIT 5;
  • Reihenfolge der Ausführung:
    • FROM Ummantelungen
      
    • WHERE color = 'grün'
      
    • SELECT item
      
    • LIMIT 5;
      
SQL für Fortgeschrittene

Lass uns üben!

SQL für Fortgeschrittene

Preparing Video For Download...