What is SQL?
SQL (Structured Query Language) is the standard language used to communicate with databases. It allows you to retrieve, filter, group, and organize information stored in systems like MySQL, PostgreSQL, or even cloud-based services like BigQuery and Snowflake. It is a powerful conversion tool between you and your data and with a small set of core commands handles the majority of what you need
In this blog, we’ll break down six essential SQL clauses — SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY — using real-world examples from the Superstore Orders table. Master these six, and you'll be able to communicate with your data clearly and effectively to answer a wide range of questions.
1. SELECT – Choose the data you want
The SELECT clause defines which columns or calculations you want returned.
Example: Return all fields from the Superstore Orders table.

Tip: The * is used when you want to return all data.
Example: List each customer's name and their state.

You can also select aggregated values or calculated fields:
Example: Show each product name with the profit margin (Profit ÷ Sales).

Tip: Always use meaningful aliases (AS) to rename computed columns
2. FROM - Specify the Source Table
As you can see from the examples above, FROM defines where your data comes from.
Example:

3. WHERE — Filter Rows Before Grouping
WHERE filters rows individually before grouping or aggregation.
Example: Find orders shipped to "California" only.

You can also chain multiple conditions:
Example: Orders in California OR New York with sales above $500

4. GROUP BY — Aggregate Your Data
For summaries like total sales per customer or average discount by region you can use GROUP BY.
Example: Find total sales per customer.

Example: Average discount by region.

Rule: Every non-aggregated column in SELECT must be listed in GROUP BY.
5. HAVING — Filter Groups After Aggregation
HAVING is used to filter aggregated results.
Example: Find customers whose total sales exceeded $10,000.

Example: Regions where average discount is greater than 10%.

Tip: WHERE filters before grouping, HAVING filters after grouping.
6. ORDER BY — Sort Your Output
Once your results are ready, use ORDER BY to arrange them nicely.
Example: Top customers by sales, highest first.

Example: Orders by most recent Ship Date.

Tip: ASC (ascending) is default. Use DESC (descending) for "highest first" or "most recent first."
Putting It All Together
Here’s a full Superstore query using all six clauses to find:
"Each Region’s total Sales and average Profit for orders shipped Second Class, but only where total Sales exceed $5,000, displayed as the highest-selling regions first".

Summary
· Start with what you want to see (SELECT)
· Tell SQL where to look (FROM)
· Filter rows (WHERE)
· Group data (GROUP BY)
· Filter groups (HAVING)
· Then organize it (ORDER BY)