SELECT & FROM: The Foundation
In any Data Analyst interview, your ability to write clean, efficient queries starts here. SELECT determines the columns, and FROM determines the data source.
- Performance Tip: Never use
SELECT *in an interview unless specifically asked. It fetches unnecessary data and slows down systems. - Readability: Always use table aliases (e.g.,
FROM orders AS o) to make complex joins easier to read later.
Practice Questions (Click to Reveal Answers)
Q1: Retrieve specific columns from a table
Prompt: Get the first_name and email of all users from the customers table.
SELECT first_name, email FROM customers;
Q2: Handling unique values (DISTINCT)
Prompt: Find all unique job_titles currently held by employees in the staff table.
SELECT DISTINCT job_title FROM staff;
Q3: Aliasing columns for cleaner reports
Prompt: Retrieve product_name but show it as “Item Name” in the output result.
SELECT product_name AS "Item Name" FROM products;
Q4: Basic math in SELECT
Prompt: The inventory table has price and tax_rate. Calculate the tax amount for each item.
SELECT product_name, (price * tax_rate) AS tax_amount FROM inventory;
Q5: Limiting results for large datasets
Prompt: We only need to see the first 10 rows from the transactions table for a quick check.
SELECT * FROM transactions LIMIT 10;
