QUERY practice Flashcards
Insert the missing statement to get all the columns from the Customers table.
________ * FROM Customers;
SELECT * FROM Customers
Write a statement that will select the City column from the Customers table.
______ _____ _____ customers;
SELECT City FROM Customers;
Select all the different values from the Country column in the Customers table.
____ _____ country FROM customers
SELECT DISTINCT country FROM customers
Select all records where the City column has the value “Berlin”.
SELECT * FROM customers ____ ___ = ______ ;
SELECT * FROM customers WHERE city = ‘Berlin’
Use the NOT keyword to select all records where City is NOT “Berlin”.
SELECT * FROM customers _________ = _______
SELECT * FROM customers WHERE NOT city = ‘Berlin’;
Select all records where the CustomerID column has the value 32.
SELECT * FROM customers ______ customer id __ __;
SELECT * FROM customers WHERE customerID = 32;
Select all records where the City column has the value ‘Berlin’ and the PostalCode column has the value 12209.
______ * FROM customers ___ city = ‘Berlin’ __ ____ = 12209
SELECT * FROM customers WHERE city = ‘Berlin’ AND postalcode = 12209
Select all records where the City column has the value ‘Berlin’ or ‘London’.
______ * FROM customers ___ city = ‘Berlin’ __ ___ = _______
SELECT * FROM customers WHERE City = ‘Berlin’ OR city = ‘London’
Select all records from the Customers table, sort the result alphabetically by the column City.
SELECT * FROM customers ______ _____
SELECT * FROM customers ORDER BY city;
Select all records from the Customers table, sort the result reversed alphabetically by the column City.
SELECT * FROM customers ____ ___ ___ ;
SELECT * FROM customers ORDER BY city DESC
Select all records from the Customers table, sort the result alphabetically, first by the column Country, then, by the column City.
SELECT * FROM customers _____ ___ ____;
SELECT * FROM customers ORDER BY country, city;
Insert a new record in the Customers table.
_____ Customers __ customername, address, city, postalcode, country__
_____ __ ‘Hekkan Burger’, ‘Gatevein 15’, ‘Sandnes’, ‘4306’, ‘Norway’__;
INSERT INTO Customers (customername, address, city, postalcode, country)
VALUES (‘Hekkan Burger’, ‘Gatevein 15’, ‘Sandnes’, ‘4306’, ‘Norway’);
Select all records from the Customers where the PostalCode column is empty.
SELECT * FROM customers WHERE ____ __ ____;
SELECT * FROM customers WHERE postalcode IS NULL;
Select all records from the Customers where the PostalCode column is NOT empty.
SELECT * FROM customers WHERE ___ ___ ___ ____;
SELECT * FROM customers WHERE postalcode IS NOT NULL
Update the City column of all records in the Customers table.
________ customers ___ city = ‘Oslo’
UPDATE customers SET city = ‘Oslo’;
Set the value of the City columns to ‘Oslo’, but only the ones where the Country column has the value “Norway”.
_____ customers __ city = ‘oslo’ ____ country = ‘Norway’
UPDATE customers SET city = ‘Oslo’ WHERE country = ‘Norway’
Update the City value and the Country value.
_____ customers __ city = ‘Oslo’ __ ______ = ‘Norway’ WHERE customerID = 32
UPDATE customers SET city = ‘Oslo’, country = ‘Norway’ WHERE customerID = 32
Delete all the records from the Customers table where the Country value is ‘Norway’.
_______ ______ customers _____ country =’Norway’
DELETE FROM customers WHERE country = ‘Norway’
Delete all the records from the Customers table.
________ customers;
DELETE FROM customers
Use the MIN function to select the record with the smallest value of the Price column.
SELECT ______ FROM products
SELECT MIN(price) FROM products