pergunta
stringlengths
8
31.4k
contexto
stringlengths
27
489
resposta
stringlengths
18
557
Lista dos 5 países que estão em primeiro lugar em número de faturas.
CREATE TABLE invoices (billing_country VARCHAR)
SELECT billing_country, COUNT(*) FROM invoices GROUP BY billing_country ORDER BY COUNT(*) DESC LIMIT 5
Lista dos 8 países que figuram no topo, por dimensão bruta/todo o volume da factura.
CREATE TABLE invoices (billing_country VARCHAR, total INTEGER)
SELECT billing_country, SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8
Lista dos 10 países mais importantes por tamanho médio da fatura.
CREATE TABLE invoices (billing_country VARCHAR, total INTEGER)
SELECT billing_country, AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10
Descobre cinco clientes que compraram algo mais recentemente.
CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE invoices (customer_id VARCHAR, invoice_date VARCHAR)
SELECT T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY T2.invoice_date DESC LIMIT 5
Encontre os 10 principais clientes por número total de encomendas.
CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE invoices (customer_id VARCHAR)
SELECT T1.first_name, T1.last_name, COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10
Lista os 10 principais clientes por vendas totais.
CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR)
SELECT T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10
Lista os 5 principais gêneros por número de faixas.
CREATE TABLE tracks (genre_id VARCHAR); CREATE TABLE genres (name VARCHAR, id VARCHAR)
SELECT T1.name, COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 5
Escreve o título de cada álbum.
CREATE TABLE albums (title VARCHAR)
SELECT title FROM albums
Lista todos os álbuns ordenados por título de álbum em ordem ascendente.
CREATE TABLE albums (title VARCHAR)
SELECT title FROM albums ORDER BY title
Lista todos os álbuns cujo título começa com A em ordem alfabética.
CREATE TABLE albums (title VARCHAR)
SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title
Escreva o nome e o apelido dos clientes de 10 faturas menos caras.
CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE invoices (customer_id VARCHAR)
SELECT T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY total LIMIT 10
Lista de montante total da fatura de Chicago, IL.
CREATE TABLE invoices (total INTEGER, billing_city VARCHAR, billing_state VARCHAR)
SELECT SUM(total) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"
Escreva o número de faturas de Chicago, IL.
CREATE TABLE invoices (billing_city VARCHAR, billing_state VARCHAR)
SELECT COUNT(*) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL"
Indicar o número de faturas dos EUA, agrupadas por estado.
CREATE TABLE invoices (billing_state VARCHAR, billing_country VARCHAR)
SELECT billing_state, COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state
Escreva o estado dos EUA com mais faturas.
CREATE TABLE invoices (billing_state VARCHAR, billing_country VARCHAR)
SELECT billing_state, COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1
Escreva o número de faturas e o total das faturas da Califórnia.
CREATE TABLE invoices (billing_state VARCHAR, total INTEGER)
SELECT billing_state, COUNT(*), SUM(total) FROM invoices WHERE billing_state = "CA"
Lista dos álbuns do Aerosmith.
CREATE TABLE artists (id VARCHAR, name VARCHAR); CREATE TABLE albums (title VARCHAR, artist_id VARCHAR)
SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Aerosmith"
Quantos álbuns tem o Billy Cobham?
CREATE TABLE artists (id VARCHAR, name VARCHAR); CREATE TABLE albums (artist_id VARCHAR)
SELECT COUNT(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Billy Cobham"
Eduardo Martins é cliente de que empresa?
CREATE TABLE customers (company VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT company FROM customers WHERE first_name = "Eduardo" AND last_name = "Martins"
Qual é o e-mail e o número de telefone da Astrid Gruber?
CREATE TABLE customers (email VARCHAR, phone VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT email, phone FROM customers WHERE first_name = "Astrid" AND last_name = "Gruber"
Quantos clientes vivem na cidade de Praga?
CREATE TABLE customers (city VARCHAR)
SELECT COUNT(*) FROM customers WHERE city = "Prague"
Quantos clientes no estado da CA?
CREATE TABLE customers (state VARCHAR)
SELECT COUNT(*) FROM customers WHERE state = "CA"
Em que país vive Roberto Almeida?
CREATE TABLE customers (country VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida"
Lista o nome dos álbuns que são lançados por aristista cujo nome tem 'Led'
CREATE TABLE artists (id VARCHAR, name VARCHAR); CREATE TABLE albums (title VARCHAR, artist_id VARCHAR)
SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%'
Quantos clientes é que o Steve Johnson tem?
CREATE TABLE employees (id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE customers (support_rep_id VARCHAR)
SELECT COUNT(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = "Steve" AND T1.last_name = "Johnson"
Qual é o título, telefone e data de contratação de Nancy Edwards?
CREATE TABLE employees (title VARCHAR, phone VARCHAR, hire_date VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT title, phone, hire_date FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"
Encontrar o nome completo dos empregados que se reportam a Nancy Edwards?
CREATE TABLE employees (id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, reports_to VARCHAR)
SELECT T2.first_name, T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = "Nancy" AND T1.last_name = "Edwards"
Qual é o endereço da empregada Nancy Edwards?
CREATE TABLE employees (address VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT address FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"
Encontre o nome completo do funcionário que apoiou o maior número de clientes.
CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE customers (support_rep_id VARCHAR)
SELECT T1.first_name, T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1
Quantos funcionários vivem no Canadá?
CREATE TABLE employees (country VARCHAR)
SELECT COUNT(*) FROM employees WHERE country = "Canada"
Qual é o número de telefone da empregada Nancy Edwards?
CREATE TABLE employees (phone VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT phone FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"
Quem é o empregado mais jovem da empresa? Escreva o nome e o apelido do empregado.
CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, birth_date VARCHAR)
SELECT first_name, last_name FROM employees ORDER BY birth_date DESC LIMIT 1
Lista de 10 empregados que trabalharam mais tempo na empresa.
CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, hire_date VARCHAR)
SELECT first_name, last_name FROM employees ORDER BY hire_date LIMIT 10
Encontre o número de funcionários cujo título é o pessoal de TI de cada cidade?
CREATE TABLE employees (city VARCHAR, title VARCHAR)
SELECT COUNT(*), city FROM employees WHERE title = 'IT Staff' GROUP BY city
Qual empregado gerencia o maior número de pessoas? Liste o nome e sobrenome do empregado e o número de pessoas que se reportam a esse empregado.
CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE employees (reports_to VARCHAR)
SELECT T2.first_name, T2.last_name, COUNT(T1.reports_to) FROM employees AS T1 JOIN employees AS T2 ON T1.reports_to = T2.id GROUP BY T1.reports_to ORDER BY COUNT(T1.reports_to) DESC LIMIT 1
Quantos pedidos tem o Lucas Mancini?
CREATE TABLE invoices (customer_id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"
Qual é a quantia total de dinheiro gasto por Lucas Mancini?
CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini"
Lista todos os tipos de mídia.
CREATE TABLE media_types (name VARCHAR)
SELECT name FROM media_types
Lista todos os diferentes tipos de gênero.
CREATE TABLE genres (name VARCHAR)
SELECT DISTINCT name FROM genres
Escreva o nome de todas as playlists.
CREATE TABLE playlists (name VARCHAR)
SELECT name FROM playlists
Quem é o compositor da faixa "Fast As a Shark"?
CREATE TABLE tracks (composer VARCHAR, name VARCHAR)
SELECT composer FROM tracks WHERE name = "Fast As a Shark"
Quanto tempo dura o "Fast As a Shark"?
CREATE TABLE tracks (milliseconds VARCHAR, name VARCHAR)
SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark"
Como se chamam as faixas cujo gênero é rock?
CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR)
SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock"
Qual é o título do álbum do qual a faixa "Balls to the Wall" pertence?
CREATE TABLE tracks (genre_id VARCHAR, name VARCHAR); CREATE TABLE albums (title VARCHAR, id VARCHAR)
SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall"
Lista de nomes de todas as faixas de "Balls to the Wall".
CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR); CREATE TABLE albums (id VARCHAR, title VARCHAR)
SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"
Lista de títulos de álbuns com o número de faixas maior que 10.
CREATE TABLE tracks (album_id VARCHAR); CREATE TABLE albums (title VARCHAR, id VARCHAR)
SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.album_id GROUP BY T1.id HAVING COUNT(T1.id) > 10
Liste o nome das faixas pertencentes ao gênero Rock e cujo tipo de mídia é arquivo de áudio MPEG.
CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)
SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" AND T3.name = "MPEG audio file"
Lista o nome das faixas pertence ao gênero Rock ou o tipo de mídia é o arquivo de áudio MPEG.
CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)
SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" OR T3.name = "MPEG audio file"
Lista o nome das faixas pertence ao gênero Rock ou gênero Jazz.
CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR)
SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock" OR T1.name = "Jazz"
Listar o nome de todas as faixas nas playlists de Filmes.
CREATE TABLE playlists (id VARCHAR, name VARCHAR); CREATE TABLE playlist_tracks (track_id VARCHAR, playlist_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR)
SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T3.id = T2.playlist_id WHERE T3.name = "Movies"
Escreva o nome da lista de reprodução que tem número de faixas maior do que 100.
CREATE TABLE playlist_tracks (playlist_id VARCHAR, track_id VARCHAR); CREATE TABLE playlists (name VARCHAR, id VARCHAR)
SELECT T2.name FROM playlist_tracks AS T1 JOIN playlists AS T2 ON T2.id = T1.playlist_id GROUP BY T1.playlist_id HAVING COUNT(T1.track_id) > 100
Listar todas as faixas compradas pelo cliente Daan Peeters.
CREATE TABLE invoices (id VARCHAR, customer_id VARCHAR); CREATE TABLE invoice_lines (track_id VARCHAR, invoice_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)
SELECT T1.name FROM tracks AS T1 JOIN invoice_lines AS T2 ON T1.id = T2.track_id JOIN invoices AS T3 ON T3.id = T2.invoice_id JOIN customers AS T4 ON T4.id = T3.customer_id WHERE T4.first_name = "Daan" AND T4.last_name = "Peeters"
Quanto custa a faixa Fast As a Shark?
CREATE TABLE tracks (unit_price VARCHAR, name VARCHAR)
SELECT unit_price FROM tracks WHERE name = "Fast As a Shark"
Encontre o nome das faixas que estão na playlist de filmes, mas não na playlist de música.
CREATE TABLE playlists (id VARCHAR, name VARCHAR); CREATE TABLE playlist_tracks (track_id VARCHAR, playlist_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR)
SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' EXCEPT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music'
Encontre o nome das faixas que estão em ambas as listas de reprodução de filmes e música.
CREATE TABLE playlists (id VARCHAR, name VARCHAR); CREATE TABLE playlist_tracks (track_id VARCHAR, playlist_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR)
SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' INTERSECT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music'
Encontrar o número de faixas em cada gênero?
CREATE TABLE tracks (genre_id VARCHAR); CREATE TABLE genres (name VARCHAR, id VARCHAR)
SELECT COUNT(*), T1.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id GROUP BY T1.name
Quantos editores há?
CREATE TABLE editor (Id VARCHAR)
SELECT COUNT(*) FROM editor
Escreva os nomes dos editores em ordem ascendente de idade.
CREATE TABLE editor (Name VARCHAR, Age VARCHAR)
SELECT Name FROM editor ORDER BY Age
Quais são os nomes e idades dos editores?
CREATE TABLE editor (Name VARCHAR, Age VARCHAR)
SELECT Name, Age FROM editor
Escreva os nomes dos editores com mais de 25 anos.
CREATE TABLE editor (Name VARCHAR, Age INTEGER)
SELECT Name FROM editor WHERE Age > 25
Mostrar os nomes dos editores com 24 ou 25 anos.
CREATE TABLE editor (Name VARCHAR, Age VARCHAR)
SELECT Name FROM editor WHERE Age = 24 OR Age = 25
Qual é o nome do editor mais novo?
CREATE TABLE editor (Name VARCHAR, Age VARCHAR)
SELECT Name FROM editor ORDER BY Age LIMIT 1
Qual é a idade dos editores?
CREATE TABLE editor (Age VARCHAR)
SELECT Age, COUNT(*) FROM editor GROUP BY Age
Por favor, indique a idade mais comum dos editores.
CREATE TABLE editor (Age VARCHAR)
SELECT Age FROM editor GROUP BY Age ORDER BY COUNT(*) DESC LIMIT 1
Mostrar os temas distintos dos periódicos.
CREATE TABLE journal (Theme VARCHAR)
SELECT DISTINCT Theme FROM journal
Indique os nomes dos editores e o tema das revistas para as quais eles servem em comitês.
CREATE TABLE journal_committee (Editor_ID VARCHAR, Journal_ID VARCHAR); CREATE TABLE editor (Name VARCHAR, Editor_ID VARCHAR); CREATE TABLE journal (Theme VARCHAR, Journal_ID VARCHAR)
SELECT T2.Name, T3.Theme FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID
Mostrar os nomes e idades dos editores e o tema das revistas para as quais eles servem em comitês, em ordem alfabética ascendente do tema.
CREATE TABLE journal_committee (Editor_ID VARCHAR, Journal_ID VARCHAR); CREATE TABLE editor (Name VARCHAR, age VARCHAR, Editor_ID VARCHAR); CREATE TABLE journal (Theme VARCHAR, Journal_ID VARCHAR)
SELECT T2.Name, T2.age, T3.Theme FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID ORDER BY T3.Theme
Mostrar os nomes dos editores que estão no comitê de revistas com vendas maiores que 3000.
CREATE TABLE journal_committee (Editor_ID VARCHAR, Journal_ID VARCHAR); CREATE TABLE editor (Name VARCHAR, Editor_ID VARCHAR); CREATE TABLE journal (Journal_ID VARCHAR, Sales INTEGER)
SELECT T2.Name FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID WHERE T3.Sales > 3000
Mostrar a identidade, o nome de cada editor e o número de comitês de revistas em que eles estão.
CREATE TABLE editor (editor_id VARCHAR, Name VARCHAR, Editor_ID VARCHAR); CREATE TABLE journal_committee (Editor_ID VARCHAR)
SELECT T1.editor_id, T1.Name, COUNT(*) FROM editor AS T1 JOIN journal_committee AS T2 ON T1.Editor_ID = T2.Editor_ID GROUP BY T1.editor_id
Mostrar os nomes dos editores que estão em pelo menos dois comitês de revistas.
CREATE TABLE editor (Name VARCHAR, Editor_ID VARCHAR); CREATE TABLE journal_committee (Editor_ID VARCHAR)
SELECT T1.Name FROM editor AS T1 JOIN journal_committee AS T2 ON T1.Editor_ID = T2.Editor_ID GROUP BY T1.Name HAVING COUNT(*) >= 2
Escreva os nomes dos editores que não fazem parte de nenhum comitê de revistas.
CREATE TABLE editor (Name VARCHAR, editor_id VARCHAR); CREATE TABLE journal_committee (Name VARCHAR, editor_id VARCHAR)
SELECT Name FROM editor WHERE NOT editor_id IN (SELECT editor_id FROM journal_committee)
Escreva a data, o tema e as vendas da revista que não tinha nenhum dos editores listados servindo no comitê.
CREATE TABLE journal_committee (journal_ID VARCHAR); CREATE TABLE journal (date VARCHAR, theme VARCHAR, sales VARCHAR); CREATE TABLE journal (date VARCHAR, theme VARCHAR, sales VARCHAR, journal_ID VARCHAR)
SELECT date, theme, sales FROM journal EXCEPT SELECT T1.date, T1.theme, T1.sales FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID
Qual é a média de vendas dos jornais que têm um editor cujo tipo de trabalho é 'Foto'?
CREATE TABLE journal_committee (journal_ID VARCHAR, work_type VARCHAR); CREATE TABLE journal (sales INTEGER, journal_ID VARCHAR)
SELECT AVG(T1.sales) FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID WHERE T2.work_type = 'Photo'
Quantas contas temos?
CREATE TABLE Accounts (Id VARCHAR)
SELECT COUNT(*) FROM Accounts
Mostrar identidades, clientes, nomes de todas as contas.
CREATE TABLE Accounts (account_id VARCHAR, customer_id VARCHAR, account_name VARCHAR)
SELECT account_id, customer_id, account_name FROM Accounts
Mostrar outros dados da conta para a conta com o nome 338.
CREATE TABLE Accounts (other_account_details VARCHAR, account_name VARCHAR)
SELECT other_account_details FROM Accounts WHERE account_name = "338"
Qual é o nome, apelido e telefone do cliente com o nome da conta 162?
CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR, account_name VARCHAR)
SELECT T2.customer_first_name, T2.customer_last_name, T2.customer_phone FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = "162"
Quantas contas tem o cliente com o nome Art e o apelido Turcotte?
CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR)
SELECT COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte"
Mostrar todas as identidades dos clientes e o número de contas de cada cliente.
CREATE TABLE Accounts (customer_id VARCHAR)
SELECT customer_id, COUNT(*) FROM Accounts GROUP BY customer_id
Mostrar o número de conta e o número de cliente com a maioria das contas.
CREATE TABLE Accounts (customer_id VARCHAR)
SELECT customer_id, COUNT(*) FROM Accounts GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
Qual é o primeiro cliente, nome e identidade com menor número de contas.
CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)
SELECT T2.customer_first_name, T2.customer_last_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) LIMIT 1
Mostrar o número de todos os clientes sem uma conta.
CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)
SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Accounts)
Mostrar os nomes e apelidos dos clientes sem qualquer conta.
CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR)
SELECT customer_first_name, customer_last_name FROM Customers EXCEPT SELECT T1.customer_first_name, T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
Mostrar nomes e apelidos distintos para todos os clientes com uma conta.
CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)
SELECT DISTINCT T1.customer_first_name, T1.customer_last_name FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id
Quantos clientes têm uma conta?
CREATE TABLE Accounts (customer_id VARCHAR)
SELECT COUNT(DISTINCT customer_id) FROM Accounts
Quantos clientes temos?
CREATE TABLE Customers (Id VARCHAR)
SELECT COUNT(*) FROM Customers
Mostre identificação, nome, apelido e telefone de todos os clientes.
CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR, customer_phone VARCHAR)
SELECT customer_id, customer_first_name, customer_last_name, customer_phone FROM Customers
Qual é o telefone e e-mail do cliente com nome Aniyah e sobrenome Feest?
CREATE TABLE Customers (customer_phone VARCHAR, customer_email VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR)
SELECT customer_phone, customer_email FROM Customers WHERE customer_first_name = "Aniyah" AND customer_last_name = "Feest"
Mostre o número de cartões de cliente.
CREATE TABLE Customers_cards (Id VARCHAR)
SELECT COUNT(*) FROM Customers_cards
Mostrar identificação, identificação do cliente, códigos do tipo de cartão, números de cartão para todos os cartões.
CREATE TABLE Customers_cards (card_id VARCHAR, customer_id VARCHAR, card_type_code VARCHAR, card_number VARCHAR)
SELECT card_id, customer_id, card_type_code, card_number FROM Customers_cards
Indicar a data de validade a partir e a data de validade até ao cartão com o número de cartão "4560596484842".
CREATE TABLE Customers_cards (date_valid_from VARCHAR, date_valid_to VARCHAR, card_number VARCHAR)
SELECT date_valid_from, date_valid_to FROM Customers_cards WHERE card_number = "4560596484842"
Qual é o nome, apelido e telefone do cliente com cartão 4560596484842.
CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_phone VARCHAR, customer_id VARCHAR); CREATE TABLE Customers_cards (customer_id VARCHAR, card_number VARCHAR)
SELECT T2.customer_first_name, T2.customer_last_name, T2.customer_phone FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.card_number = "4560596484842"
Quantos cartões tem o cliente Art Turcotte?
CREATE TABLE Customers_cards (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR)
SELECT COUNT(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte"
Quantos cartões de débito temos?
CREATE TABLE Customers_cards (card_type_code VARCHAR)
SELECT COUNT(*) FROM Customers_cards WHERE card_type_code = "Debit"
Quantos cartões de crédito tem a cliente Blanche Huels?
CREATE TABLE Customers_cards (customer_id VARCHAR, card_type_code VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR)
SELECT COUNT(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Blanche" AND T2.customer_last_name = "Huels" AND T1.card_type_code = "Credit"
Mostrar todas as identidades dos clientes e o número de cartões de cada cliente.
CREATE TABLE Customers_cards (customer_id VARCHAR)
SELECT customer_id, COUNT(*) FROM Customers_cards GROUP BY customer_id
Qual é a identificação do cliente com mais cartões, e quantos ele tem?
CREATE TABLE Customers_cards (customer_id VARCHAR)
SELECT customer_id, COUNT(*) FROM Customers_cards GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1
Mostrar o número de identificação, o nome e o apelido de todos os clientes com pelo menos dois cartões.
CREATE TABLE Customers_cards (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)
SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2
Qual é o número de clientes, nome e sobrenome com o menor número de contas.
CREATE TABLE Customers_cards (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)
SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) LIMIT 1
Indicar todos os códigos do tipo de cartão e o número de cartões de cada tipo.
CREATE TABLE Customers_cards (card_type_code VARCHAR)
SELECT card_type_code, COUNT(*) FROM Customers_cards GROUP BY card_type_code