Learn SQL

Introduction to SQL: SELECT, Columns, Aliases, and Sorting Results

Your first SQL queries do not need to be complicated. Start with SELECT, choose the columns you need, name results clearly, and sort rows intentionally.

Published 2026-05-09·Updated 2026-05-09

Your first SQL queries should feel small

SQL can eventually join tables, calculate rankings, reshape nested data, and summarize millions of rows. But the first chapter of real SQL practice should feel much smaller: ask for rows, choose columns, name results clearly, and sort the output.

SQL for Files is designed for that kind of practice. You can open the browser app, load guided sample data or your own CSV, JSON, and Parquet files, and run SQL locally with DuckDB WASM. There is no database server to configure before writing your first query.

Chapter focus

The Introduction to SQL chapter covers SELECT, selecting columns, aliases, and ORDER BY using a small employees table.

Start with SELECT * to see the table

The most fundamental SQL statement is SELECT. When you are exploring a table for the first time, SELECT * is a useful way to inspect every column and every row in a small sample table.

SELECT *
FROM employees;

The asterisk means all columns. This is not always what you want in production analysis, but it is a clear starting point when you are learning what a table contains.

Choose only the columns you need

Once you know the shape of the table, the next step is to request only the columns that matter. This makes your query easier to read and keeps your result focused.

SELECT name, department
FROM employees;
  • Selecting specific columns makes your intent clear.
  • It avoids returning data you do not need.
  • It prepares you for larger real-world tables with many columns.

Use aliases to make results readable

Aliases let you give query results clearer temporary names. The table itself does not change. Only the output of that query uses the alias.

SELECT
  name AS employee_name,
  salary AS annual_salary
FROM employees;

Aliases become especially helpful when you calculate new values or write longer queries. A name like annual_bonus is much easier to understand than an unnamed expression such as salary * 0.10.

Sort intentionally with ORDER BY

SQL does not guarantee a meaningful row order unless you ask for one. ORDER BY tells SQL how the result should be sorted.

SELECT name, salary
FROM employees
ORDER BY salary DESC;

Use ASC for ascending order and DESC for descending order. You can also sort by more than one column, such as department first and name second.

SELECT name, department, salary
FROM employees
ORDER BY department, name;

Practice the full Introduction to SQL chapter

The second Learn SQL chapter in SQL for Files turns these ideas into short hands-on exercises. You load a small employees table, run your first SELECT query, pick individual columns, rename output columns, and sort the result set.

  1. Start with Your First Query to retrieve every row and column.
  2. Continue to Selecting Columns to focus the result.
  3. Use Naming Results with Aliases to make output easier to read.
  4. Finish with Sorting Results to control row order with ORDER BY.

Continue in the editor

Open SQL for Files to add your own CSV, JSON, or Parquet files and try these examples locally in your browser.

Open editor