Choosing Columns with SELECT
Query database tables and retrieve specific columns instead of dumping unnecessary data.
Why this matters
SQL is how analysts ask questions of data in almost every company. Every query you will ever write starts with SELECT.
Tables Have Rows and Columns
A table is like a spreadsheet. Columns are the headings. Rows are the records. Each column has a name and a type of data, such as text or number.
In real life: A table is like a spreadsheet. Each column is a heading (like city) and each row is one record (one customer).
Ask Only for the Columns You Need
SELECT * returns every column, which is slow and messy. Name just the columns you need, separated by commas.
In real life: At a restaurant you order "the rice and the stew", not "everything on the menu". Naming the columns is the same: ask only for what you will use.
Your practice task
The marketing team needs a customer directory. Query the customers table and retrieve only two columns: customer_name and city.
How to do it
- Open THE DATA panel and find the customers table.
- Decide which two columns the marketing team needs.
- Replace the star in the starter query with just those columns.
- Press Run proof and read the checklist.
Practice it for free in the app. You get instant checks that show what you got right and what to fix. A lesson takes about two minutes and you can try as many times as you like.
Quick reference: Basic SELECT Query
Fetches specified fields from a database table.
SELECT col1, col2 FROM table_name;
More lessons in this course
- Filtering Rows with WHEREUse WHERE clauses to isolate specific records and exclude irrelevant or cancelled data.
- Sorting & Capping with LIMITOrder query results and cap row counts to find top transactions quickly.
- Aggregating Totals with COUNT & SUMCalculate high-level summary metrics across thousands of rows in a single query.