TryBench
Data Analysis & SQL · Foundation lesson 1 of 19

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

  1. Open THE DATA panel and find the customers table.
  2. Decide which two columns the marketing team needs.
  3. Replace the star in the starter query with just those columns.
  4. 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;

Practice this lesson free

More lessons in this course

See all 19 lessons in Data Analysis & SQL