SELECT Statements SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Use a Table Alias

Alias employees as e and return e.first_name with e.salary.

Exercise brief

Understand the request

Data engineering apprentice The query will soon join more tables, so the source needs a concise alias now.

Return e.first_name and e.salary after giving the employees table the alias `e`. Table aliases are essential once queries grow to multiple tables.

Return

  • Return first_name and salary.

Constraints

  • Qualify both projected columns with the table alias.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

employees

  • first_nameVARCHAR(50)
  • salaryINTEGER

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Add `AS e` (or just ` e`) right after the table name in FROM. Once aliased, you must use the alias to qualify columns (e.first_name).

Hint 2

Most engines let you skip the AS keyword: `FROM employees e` is equivalent to `FROM employees AS e`.

Hint 3

Introduce a short alias after employees and use that alias to qualify both projected columns.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT e.first_name, e.salary FROM employees AS e;

Why this works

Table aliases shorten table names and disambiguate columns when multiple tables share a column name (e.g. id). Even in single-table queries, aliasing is a good habit because it makes the query trivial to extend with JOINs later.

Success check

Every employee appears once with first_name and salary projected through the e table alias.

Expected result

Use this output to verify values, aliases, ordering, and row count.

first_namesalary
John120000
Alice85000
Bob80000
Carol60000
David70000
Emma95000
Frank65000
Grace90000
Henry55000
Ivy68000

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.