What command retrieves all data from a table?
SELECT * FROM table_name;
What keyword is used to filter results?
WHERE
What keyword is used to sort results?
ORDER BY
What does FROM do?
Specifies which table to retrieve data from
What is a way that SQL could be used in real life.
Many correct answers.
How do you retrieve only the ProductName column from Products?
SELECT ProductName FROM Products;
How do you find customers from Mexico?
SELECT * FROM Customers WHERE Country = 'Mexico';
How do you sort products from lowest to highest price?
ORDER BY Price ASC;
What does WHERE do?
Filters results based on a condition
How do you find the lowest-priced product?
ORDER BY Price ASC
What does DISTINCT do?
Removes duplicate values
How do you find products that cost more than $50?
SELECT * FROM Products WHERE Price > 50;
How do you sort customers alphabetically?
ORDER BY CustomerName ASC;
What does ORDER BY ColumnName ASC do?
Sorts in ascending order
How do you find all employees hired before 1990?
SELECT * FROM Employees WHERE HireDate < '1990-01-01';
What does ORDER BY do?
Sorts the results
How do you find employees hired before 2000?
SELECT * FROM Employees WHERE HireDate < '2000-01-01';
How do you sort employees by last name in reverse order?
ORDER BY LastName DESC;
What does ORDER BY ColumnName DESC do?
Sorts in descending order
How do you find all customers from France and Germany?
SELECT * FROM Customers WHERE Country = 'France' OR Country = 'Germany';
What happens if you run SELECT * FROM Customers; with no WHERE clause?
It returns all customers
How do you find customers from the USA or Canada?
SELECT * FROM Customers WHERE Country = 'USA' OR Country = 'Canada';
How do you sort orders by date, newest first?
ORDER BY OrderDate DESC;
What does DISTINCT do?
Shows only unique values
How would a store owner use SQL to find the most expensive product?
ORDER BY Price DESC