SQL for Beginners: 10 Commands Every Data Analyst Uses


SQL is the language analysts use to get data out of databases. You do not need to memorise every function. In day-to-day work, a short set of commands appears again and again: you choose columns, filter rows, join tables, and summarise results. If you can write those queries with confidence, you can answer most of the questions a team will ask.

Here are the 10 commands every beginner should practise first, and how they fit together in a real query.

The building blocks: SELECT, FROM and WHERE

Almost every query starts the same way. SELECT names the columns you want to see. FROM names the table. WHERE keeps only the rows that match a condition, such as orders from last month or customers in one country. If you can write this pattern, you can already explore a dataset without exporting everything into a spreadsheet.

Shape the result: ORDER BY, LIMIT and DISTINCT

ORDER BY sorts the result, for example from the largest sale to the smallest. LIMIT (or TOP in SQL Server) returns only the first N rows, which is useful when you want a quick preview and do not need the full table. DISTINCT removes duplicate values, such as a unique list of product categories. These three commands make results easier to read and faster to check.

Combine and summarise: JOIN, GROUP BY and HAVING

Useful answers often sit in more than one table. JOIN combines related rows, such as linking an orders table to a customers table with a shared customer ID. GROUP BY then summarises data into categories, usually with aggregate functions such as COUNT, SUM or AVG, for example total revenue by month. HAVING filters those groups after they have been calculated. That is the key difference from WHERE: WHERE filters raw rows first, while HAVING filters the summarised groups.

Add logic with CASE

CASE lets you write if-then logic inside a query. You can flag late orders, put customers into spending bands, or create a simple yes/no column for a report. Used with GROUP BY, it becomes a flexible way to build categories without changing the original data.

A good practice habit is to write one complete query that uses several of these commands together, then change one clause at a time and check the result. Work with a small, realistic table so you can see whether the numbers make sense.

Want to learn SQL step by step?

SQL for Data Analysis teaches these commands with practical examples and exercises, so you can move from simple SELECT statements to useful business queries.

Comments

Popular posts from this blog

Excel Skills Every Data Analyst Needs (8 Must-Know Functions)

7 Steps to Become a Data Analyst in 2027 (A Practical Roadmap)