sqlcmd.net validated sql reference
beginner selecting MySQL MariaDB SQL Server PostgreSQL

Rename Output Columns With AS

Use `AS` to give result columns clearer labels without changing the underlying table schema.

Docker-validated Not currently validation-green

Rename selected columns for clearer output

The data does not change, only the column labels in the result set. first_name is shown as employee_name, and salary is shown as annual_salary.

Rows loaded before the example query runs.
Setup
CREATE TABLE employees (id INT, first_name VARCHAR(50), salary INT);

INSERT INTO
  employees (id, first_name, salary)
VALUES
  (1, 'Ada', 90000),
  (2, 'Linus', 95000);
Shared across supported engines.
SQL
SELECT
  first_name AS employee_name,
  salary AS annual_salary
FROM
  employees
ORDER BY
  id;
Returned rows for the shared example.
employee_nameannual_salary
Ada90000
Linus95000

All engines use the same `AS` alias syntax for output column names in this example.

Where this command helps.

  • renaming columns for a report or export
  • giving calculated expressions readable names in query output

What the command is doing.

Column aliases rename expressions or columns in the query result. They make output easier to read in reports, dashboards, and ad hoc analysis, especially when the original column names are too technical or when a calculated expression needs a readable label.