SQL for Beginners: A First Week of Practice Queries

Student laptop code desk
Image by salinger from Pixabay

You can learn enough SQL in seven days to read a real database and answer simple business questions. You won't be job-ready in a week, but you will know the five or six commands that make up most of everyday work. This plan uses one small practice table, about 30 to 60 minutes a day, and nothing you have to pay for.

What SQL is for, and who needs it

SQL is the language used to ask questions of data stored in tables. A shop's sales records, a school's results, a fintech app's transactions: when these sit in a database, SQL is how people pull out "which products sold most last month?" or "which customers haven't paid?"

It shows up in data analyst, business analyst, operations, product and finance roles. It also helps if you only use spreadsheets today, because once a file grows past a few thousand rows, questions get easier to answer with a query. If you are still weighing where to start, see our guide on learning data analysis free on a phone with limited data.

Set up without spending money or burning data

You don't need to install a server. Pick one of these:

  • A browser-based SQL practice site. Many free ones let you type queries against sample tables. Load the page once, and the practice itself uses very little data.
  • SQLite on a laptop. It is a free, small database that runs from one file. Good if power or data is unreliable, since it works offline after the download.
  • An AI chat tool as a tutor. Use it to explain errors, not to write every query for you. More on that below.

Whatever you choose, create the same practice table so you can follow along. Here is a hypothetical one for a small shop called sales:

iditemcategoryqtyprice_nairacitysale_date
1Rice 50kgGrains278000Lagos2026-09-02
2Palm oil 25LOils165000Ibadan2026-09-03
3Beans 50kgGrains390000Lagos2026-09-05
4Garri 25kgGrains432000Abuja2026-09-09

The prices are made up for practice. Add 15 to 30 more rows of your own, with repeated cities and categories, because grouping needs repetition to be interesting.

Day 1: SELECT and FROM

Every query starts by saying what you want and where it lives.

  • SELECT * FROM sales; shows every column and row.
  • SELECT item, city FROM sales; shows only two columns.
  • SELECT DISTINCT city FROM sales; lists each city once.

Practice: list all items, then list the unique categories, then the unique cities. End every query with a semicolon. Forgetting it is the most common first error.

Day 2: WHERE, filtering rows

WHERE keeps only the rows that match a condition.

  • SELECT * FROM sales WHERE city = 'Lagos';
  • SELECT * FROM sales WHERE qty >= 3;
  • SELECT * FROM sales WHERE category = 'Grains' AND city = 'Abuja';
  • SELECT * FROM sales WHERE city IN ('Lagos','Ibadan');

Text goes in single quotes; numbers don't. Practice: find sales above ₦70,000, find Grains sales in Lagos, and find sales that are not in Abuja using city <> 'Abuja'.

Day 3: ORDER BY, LIMIT and calculated columns

Sorting and doing arithmetic make results readable.

  • SELECT * FROM sales ORDER BY price_naira DESC LIMIT 3; gives the three highest prices.
  • SELECT item, qty * price_naira AS total FROM sales; makes a new column called total.

In this table, price_naira is treated as the price of the line, so check how your own data defines it before multiplying. Mixing up "unit price" and "line price" is a classic source of wrong answers in real work.

Practice: show the five biggest sales by total value, sorted high to low.

Day 4: Aggregates, COUNT, SUM, AVG

Aggregates collapse many rows into one number.

  • SELECT COUNT(*) FROM sales; counts rows.
  • SELECT SUM(qty) FROM sales; adds quantities.
  • SELECT AVG(price_naira) FROM sales WHERE city = 'Lagos';
  • SELECT MIN(sale_date), MAX(sale_date) FROM sales;

Practice: how many sales were in Lagos? What is the total quantity of Grains sold? What is the earliest sale date?

Day 5: GROUP BY, the most useful command

GROUP BY lets you get one aggregate per category, like a pivot table in a spreadsheet.

SELECT city, COUNT(*) AS num_sales, SUM(price_naira) AS revenue FROM sales GROUP BY city ORDER BY revenue DESC;

Read it aloud: "for each city, count the sales and add up the money, then rank cities by money." Add HAVING SUM(price_naira) > 100000 after GROUP BY to keep only big groups. WHERE filters rows before grouping; HAVING filters groups after. That distinction comes up in interviews.

Practice: revenue per category, then sales per city per month.

Day 6: JOIN, combining two tables

Real databases split information across tables. Create a second one, customers, with columns id, name and city, and add a customer_id column to sales. Then:

SELECT customers.name, SUM(sales.price_naira) AS spent FROM sales JOIN customers ON sales.customer_id = customers.id GROUP BY customers.name;

The ON clause tells SQL which column matches in each table. A plain JOIN keeps only matches. A LEFT JOIN keeps every row from the first table even without a match, which is how you find customers who never bought anything: add WHERE sales.id IS NULL.

Joins are where most beginners get stuck, so spend the whole day here. Draw the two tables on paper and trace one row across.

Day 7: A mini project you can show

Answer five business questions in writing, with the query and a one-sentence finding for each:

  1. Which city brings in the most money?
  2. Which category sells the most units?
  3. What are the top three customers by spend?
  4. Which customers have never bought?
  5. What is the average sale value per month?

Put this in a document or a public notes page. It becomes a portfolio item; our guide to building a simple online portfolio with AI help shows how to present it.

Using AI as a tutor without cheating yourself

An AI assistant is useful for three things: explaining an error message, explaining a query line by line, and generating fresh practice questions. It is a poor choice for writing every answer, because you will recognise queries but not be able to produce them in a test.

A good habit: write your attempt first, paste it with the error, and ask "what is wrong and why?" Check the result by running it. AI can write queries that run but answer the wrong question, so always sanity-check totals against a few rows you can add by hand. Also, never paste real customer data into a chat tool; see using AI at work without leaking customer data. Use invented rows like the ones above.

For wording your requests, the prompting basics guide helps.

Common mistakes

  • Using SELECT * on huge tables. Choose columns and add LIMIT while exploring.
  • Forgetting GROUP BY columns. Every non-aggregated column in SELECT must appear in GROUP BY.
  • Comparing with NULL using =. Use IS NULL.
  • Trusting a join blindly. If row counts jump after a join, you probably have duplicates in the matching column.
  • Memorising instead of practising. Type queries. Don't only read them.

Small syntax differences exist between systems such as MySQL, PostgreSQL, SQLite and SQL Server, particularly for dates. The basics above work across them; check the documentation of your tool for date functions.

Frequently asked questions

Do I need a laptop?

A laptop is easier, but many browser-based practice sites work on a phone. Typing long queries on a phone is slow, so a laptop helps once you pass week one.

Is SQL still worth learning with AI around?

Yes. AI can draft queries, but someone has to check that the query answers the right question. Employers who ask for SQL usually want that checking ability.

What should I learn after week one?

Dates and text functions, subqueries, and window functions, then pair SQL with a spreadsheet or a charting tool so you can present findings.

Can I get paid with only SQL?

Rarely on its own. It pays best combined with reporting, spreadsheets or a business domain you understand, such as retail, logistics or finance.

Your next step today

Create the sales table, add 20 rows, and run the three Day 1 queries. Then book the other six days into your calendar, even if each session is only 30 minutes.


Results from any side hustle or online work vary widely, and nothing here is a promise of income. Be wary of anyone who asks you to pay upfront to start earning.

John Paul

John Paul is a senior editor at HotNaija. twitter

Previous Post Next Post