Lesson 1 of 5

Progress: 0/4 exercises solved (0%)

Solve all exercises below to unlock the next lesson.

SELECT: choosing columns

Lesson Description

Pick the columns you want from a table.

Easy Project

Mini project: Turn this lesson into a real-world query artifact by writing one clean business report query and validating output quality.

SELECT — pick your columns

Every SQL query starts with SELECT. It tells the database which columns to return.

Basic syntax

SELECT column1, column2
FROM table_name;

Selecting specific columns

Listing columns explicitly is best practice — it self-documents intent and is resilient to schema changes.

SELECT first_name, last_name, salary
FROM employees;

Wildcard: SELECT *

Returns every column. Useful for quick exploration, but avoid it in production — future columns appear automatically and can break downstream code.

SELECT * FROM employees;

Column aliases with AS

AS renames a column in the result set. The underlying table is unchanged.

SELECT
  first_name  AS given_name,
  salary      AS monthly_pay
FROM employees;

Computed expressions

Arithmetic and string operations work directly in SELECT:

SELECT
  first_name,
  salary * 12                    AS annual_salary,
  first_name || ' ' || last_name AS full_name
FROM employees;

Key rules

  • Columns are separated by commas.
  • FROM specifies the source table.
  • Aliases set in SELECT cannot be referenced in WHERE — they do not exist yet at that stage.
  • Without WHERE, every row is returned.

Learning context

This lesson is part of SQL Fundamentals. Focus on the core idea in SELECT: choosing columns, then validate with deliberate practice.

What to master

  • Understand clause order and intent
  • Write deterministic result queries
  • Use clear aliases and readable structure

Common mistakes

  • Skipping ORDER BY in final outputs
  • Using joins before validating base rows
  • Not checking row counts after changes

High-level strategy

  • Start simple, then layer complexity
  • Run often and compare expected shape
  • Refactor with CTEs when logic grows

Task ladder

  1. Baseline query: get a correct first output.
  2. Add one complication: edge case, join, filter, or ranking rule.
  3. Re-run and refine until output is stable and explainable.

Transparent data checks

  • Check row count before and after each major clause.
  • Validate one manual sample row for correctness.
  • Confirm final ordering and column naming for trust.

Retention loop

  • Run the solution once.
  • Rewrite from memory with one variation.
  • Explain the logic in plain English in one sentence.

Logical reasoning for commands

WHERE

Why: Limits rows to only the business-relevant subset.

Memory cue: Filter early to reduce noise.

ORDER BY

Why: Makes output deterministic and reviewable.

Memory cue: No ORDER BY means no guaranteed row order.

AS alias

Why: Makes output columns readable for teams and reports.

Memory cue: If the name is clear, the query is easier to trust.

Concept check

Quick check: SELECT: choosing columns

3 quick questions. One at a time. Instant score at the end.

Exercise 1

List all first and last names

Enterprise Workforce Analyticseasy

Return the first_name and last_name of every employee.

Run a query to see results here.
Exercise 2

Rename the salary column

Enterprise Workforce Analyticseasy

Return every employee's first_name and their salary aliased as monthly_pay.

Run a query to see results here.
Exercise 3

Compute annual salary

Enterprise Workforce Analyticseasy

Return first_name, last_name, and salary * 12 aliased as annual_salary for every employee.

Run a query to see results here.
Exercise 4

Job titles and salary range

Enterprise Workforce Analyticseasy

Return title, min_salary, and max_salary from the jobs table, ordered by min_salary ascending.

Run a query to see results here.

Lesson 1 of 5

0/4 solved (0%)

Finish this lesson to unlock next.