SQL is one of the most important tools in any analyst’s toolkit. Whether you’re pulling transactional sales data, cleaning messy records, or preparing insights for dashboards, SQL is often the very first step.
If you’re just getting started, here are the five SQL queries that will cover 80% of your daily work as an analyst.
Manual effort?
Nah, let’s automate these data management tasks!
SELECT
The Foundation
This is your bread and butter: pulling data from a table.
Think of SELECT as your “give me the data” query. It’s the most basic — and the most powerful — command in SQL.
CODE SNIPPET:
SELECT customer_id, first_name, last_name, email
FROM customers;
WHERE
Filtering Results
Analysts rarely want all the data. WHERE lets you focus on what matters.
CODE SNIPPET:
SELECT *
FROM orders
WHERE order_date >= ‘2025-01-01’
AND status = ‘Shipped’;
For example, the query above pulls only shipped orders after January 1, 2025. Trust me, this is especially important when you’re working with millions of records that go back years. You do not want to be poring over a list that seems infinite and neither does the recipient who may have requested the ad-hoc report from you.
WHERE can be used to filter by categories or conditions as well.
GROUP BY
Summarizing Data
Aggregation is where insights begin. GROUP BY helps you summarize large datasets.
CODE SNIPPET:
SELECT product_id, COUNT(*) AS total_orders
FROM orders
GROUP BY product_id;
Now you can see which products have the most orders. Perfect for identifying bestsellers or analyzing trends.
JOIN
Combining Tables
Most real-world data lives in multiple tables. JOIN lets you stitch it together.
CODE SNIPPET:
SELECT c.customer_id, c.first_name, o.order_id, o.order_date
FROM customers AS c
JOIN orders AS o
ON c.customer_id = o.customer_id;
This connects customer details with their order history. Almost every analytics project requires joins at some point.
JOIN is often the most confusing query that beginners come across since there are different types. It can get confusing but don’t let that intimidate you, I’ll cover the different types of joins in a separate post 🙂
CASE
Adding Logic to Queries
Sometimes you need to create quick categories without exporting to Excel or Python. That’s where CASE comes in.
CODE SNIPPET:
SELECT order_id, total_amount,
CASE WHEN total_amount > 500 THEN ‘High Value’
ELSE ‘Standard’
END AS order_type
FROM orders;
This example creates a new column that classifies orders as “High Value” or “Standard.”
WRAPPING UP
These five SQL queries are the building blocks of data analysis. Master them, and you’ll unlock the ability to:
- Extract exactly the data you need
- Summarize and explore patterns
- Connect multiple sources together
- Add quick insights directly in SQL
Once you’re comfortable with these basics, you’ll be ready for more advanced techniques like CTEs, window functions, and query optimization.
Until next time,
Ardonna •ᴗ•
author’s note
Hi, I’m Ardonna Cardines — a data analyst and creator of Mercury Musings, where business meets imagination through data. I love blending analytics, design, and storytelling to make learning data modeling and visualization approachable — one creative dataset at a time.
If you’ve enjoyed this post, I’d love for you to follow along.
You can subscribe to my blog for new tips + tutorials, creative datasets, and behind-the-scenes projects — or connect with me on LinkedIn where I share updates and learning resources for analysts and data storytellers.
