What is T-SQL, and why does it matter in Africa?
T-SQL (Transact-SQL) is the language that runs inside Microsoft SQL Server — the database engine used by thousands of enterprises across Nigeria, Kenya, South Africa, Ghana, and beyond. Banks, telecoms, fintech platforms, healthcare systems, logistics companies: they all store their data in SQL Server, and they all need people who can query it.
When you know T-SQL, you can answer business questions directly from the data. No waiting for an engineer. No exporting to Excel. You open a query window, write a few lines, and the answer is right there.
This lesson covers the two most fundamental tools in that process: SELECT and WHERE.
Our dataset: PalmPay-style mobile money transactions
Imagine you're a junior data analyst at a Nigerian mobile money company — similar to PalmPay or OPay. The transactions team hands you access to a table called mobile_transactions. It looks like this:
| transaction_id | customer_id | transaction_type | amount_ngn | status | created_at | state |
|---|---|---|---|---|---|---|
| TXN-10001 | C-4421 | transfer | 12500.00 | completed | 2025-01-15 09:42:11 | Lagos |
| TXN-10002 | C-7783 | airtime | 500.00 | completed | 2025-01-15 10:01:04 | Abuja |
| TXN-10003 | C-4421 | transfer | 75000.00 | failed | 2025-01-15 10:44:30 | Lagos |
| TXN-10004 | C-9102 | billpay | 8800.00 | completed | 2025-01-15 11:15:00 | Port Harcourt |
| TXN-10005 | C-3356 | transfer | 50000.00 | completed | 2025-01-15 11:58:44 | Kano |
| TXN-10006 | C-7783 | airtime | 200.00 | pending | 2025-01-15 12:30:19 | Abuja |
Each row is one transaction. Your job: write queries to extract exactly the data the business needs.
Part 1 — SELECT: Choose your columns
Every T-SQL query starts with SELECT. It tells the database which columns you want back. The simplest possible query retrieves everything:
SELECT *
FROM mobile_transactions;
The * is a wildcard — it means "every column." This returns all 7 columns for every row in the table. In a real fintech database that might be millions of rows. You'd never run SELECT * in production. But it's fine to learn with.
More often, you'll name the columns you actually need:
SELECT transaction_id,
customer_id,
amount_ngn,
status
FROM mobile_transactions;
Why name specific columns? Two reasons. First, it's faster — the database doesn't retrieve data you don't need. Second, it's clearer — anyone reading your query immediately knows which fields matter for this analysis.
Part 2 — WHERE: Filter your rows
SELECT controls which columns you see. WHERE controls which rows you see. This is where T-SQL starts to feel powerful — instead of pulling the whole table, you can ask very specific business questions.
Example 1: Only completed transactions
The operations team wants a list of every transaction that went through successfully. You need rows where status = 'completed':
SELECT transaction_id,
customer_id,
amount_ngn,
status
FROM mobile_transactions
WHERE status = 'completed';
From our sample data, this returns 4 rows: TXN-10001, TXN-10002, TXN-10004, and TXN-10005. The failed and pending transactions are excluded.
Example 2: High-value transfers
The compliance team flags large transfers for review. Show them every completed transfer above ₦20,000:
SELECT transaction_id,
customer_id,
amount_ngn,
state
FROM mobile_transactions
WHERE transaction_type = 'transfer'
AND status = 'completed'
AND amount_ngn > 20000;
Three conditions, all connected with AND. A row only appears if it satisfies all three. From our sample: only TXN-10005 (₦50,000 transfer from Kano, completed) passes all three filters.
AND vs OR: AND is more restrictive — every condition must be true. OR is more permissive — at least one condition must be true. Most business queries start with AND: you're looking for a specific subset, not a broad one.
Example 3: All transactions from Lagos or Abuja
The regional team wants data from two states. Use IN — it's cleaner than stacking OR conditions:
SELECT transaction_id,
customer_id,
amount_ngn,
state,
status
FROM mobile_transactions
WHERE state IN ('Lagos', 'Abuja');
This returns 4 rows: TXN-10001, TXN-10003 (Lagos), TXN-10002, TXN-10006 (Abuja). IN is the shorthand for state = 'Lagos' OR state = 'Abuja' — but much easier to read when you have 5+ values.
What you just learned
In one lesson, you can now:
- Use SELECT to pick which columns to return
- Use FROM to specify the table
- Use WHERE to filter rows by value, range, or list
- Chain conditions with AND and IN
- Apply all of this to a real-world business scenario
This is Week 1 of 8 in the T-SQL Mastery program. By Week 4 you'll be writing joins, aggregations, and subqueries against real enterprise datasets. By Week 8, you'll have a portfolio project you can show in interviews.
Your turn — 3 queries to write
Using the mobile_transactions table above, try writing these queries on your own. Don't worry about running them yet — just write the SQL:
-
1
Select only the
transaction_id,amount_ngn, andcreated_atcolumns for all rows where the transaction type is airtime. - 2 Find all transactions for customer C-7783 that have a completed status.
-
3
List all failed or pending transactions (use
IN), showing onlytransaction_id,status, andamount_ngn.
Hint for #3: WHERE status IN ('failed', 'pending')
Get 3 more free lessons →
Week 2 covers JOINs. Week 3 covers GROUP BY and aggregations. Week 4 covers window functions. All free, straight to your inbox.
- JOINs across tables
- COUNT, SUM, AVG in T-SQL
- GROUP BY for business reporting
- Real African dataset examples
Ready for the full 8-week program?
Live Saturday classes, real enterprise projects, 1-on-1 mentorship, and a portfolio you can show in interviews. Taught by a working data engineer with 8+ years of production T-SQL.
Enroll Now →Classes start May 9, 2026 · Limited seats