Filtrando múltiplos critérios

SQL Intermediário com IA

Jasmin Ludolf

Senior Data Science Content Developer

Filtrando múltiplos critérios

Filtrando múltiplos critérios como gêneros de livros e datas de lançamento

SQL Intermediário com IA

Todos os requisitos são verdadeiros

Prompt: Mostrar filmes em inglês com menos de 90 minutos lançados após 1990

SELECT title, release_year, duration
FROM films
WHERE release_year > 1990
AND language = 'English'
AND duration < 90;
|title                   |release_year|duration|
|------------------------|------------|--------|
|Showdown in Little Tokyo|1991        |79      |
|Stone Cold              |1991        |88      |
|Teenage Mutant Ninja ...|1991        |88      |
...
SQL Intermediário com IA

Ou

Prompt: Mostrar filmes em inglês ou francês lançados após 1990

SELECT title, release_year, language 
FROM films
WHERE (language = 'English' OR language = 'French') AND release_year > 1990;
|title                   |release_year|language|
|------------------------|------------|--------|
|Beastmaster 2: Throug...|1991        |English |
|Bill & Ted's Bogus Jo...|1991        |English |
|Boyz n the Hood         |1991        |English |
...
SQL Intermediário com IA

Parênteses

SELECT title, release_year, language 
FROM films
WHERE language = 'English' OR language = 'French' AND release_year > 1990;
|title              |release_year|language|
|-------------------|------------|--------|
|The Broadway Melody|1929        |English |
|Hell's Angels      |1930        |English |
|A Farewell to Arms |1932        |English |
|42nd Street        |1933        |English |
...
SQL Intermediário com IA

Intervalos de dados

Prompt: Mostrar títulos de filmes e ano de lançamento entre 1990 e 1999

SELECT title, release_year
FROM films
WHERE release_year BETWEEN 1990 AND 1999;
|title                      |release_year|
|---------------------------|------------|
|Arachnophobia              |1990        |
|Back to the Future Part III|1990        |
...
  • Equivalente a release_year >= 1990 AND release_year <= 1999
SQL Intermediário com IA

Verificando múltiplos valores

Prompt: Mostrar títulos de filmes e país para filmes do Japão, Itália ou Espanha

SELECT title, country
FROM films
WHERE country = 'Japan' OR country = 'Italy' OR country = 'Spain';
|title                         |country|
|------------------------------|-------|
|Seven Samurai                 |Japan  |
|A Fistful of Dollars          |Italy  |
|The Good, the Bad and the Ugly|Italy  |
...
SQL Intermediário com IA

Verificando múltiplos valores

Prompt: Mostrar títulos de filmes e país para filmes do Japão, Itália ou Espanha

SELECT title, country
FROM films
WHERE country IN ('Japan', 'Italy', 'Spain');
|title                         |country|
|------------------------------|-------|
|Seven Samurai                 |Japan  |
|A Fistful of Dollars          |Italy  |
|The Good, the Bad and the Ugly|Italy  |
...
SQL Intermediário com IA

Excluindo múltiplos valores

Prompt: Mostrar títulos de filmes e idioma, exceto em inglês e francês

SELECT title, language
FROM films
WHERE language NOT IN ('English', 'French')';
|title        |language|
|-------------|--------|
|Metropolis   |German  |
|Pandora's Box|German  |
|Seven Samurai|Japanese|
...
SQL Intermediário com IA

Verificar filtros complexos

$$

  • AND: requer múltiplas condições

  • OR: aceita alternativas

  • BETWEEN: intervalos

  • IN / NOT IN: múltiplos valores

  • Parênteses para agrupar condições e controlar a lógica

IA em um computador

SQL Intermediário com IA

Vamos praticar!

SQL Intermediário com IA

Preparing Video For Download...