2 Day Developer > Using SQL > Retrieving Data With Queries > Using a Column Alias to Cha...
Using a Column Alias to Change Headings When Selecting Data |
Previous |
Next |
When displaying the result of a query, SQL normally uses the name of the selected column as the column heading. You can change a column heading by using a column alias to make the heading more descriptive and easier to understand.
You can specify the alias after the column name in the SELECT
list using a space as a separator. If the alias contains spaces or special characters, such as number sign # or dollar sign $, or if it is case-sensitive, enclose the alias in quotation marks " ".
Example: Using a Column Alias for a Descriptive Heading in a SQL Query shows the use of a column alias to provide a descriptive heading for each of the columns selected in a query.
Using a Column Alias for a Descriptive Heading in a SQL Query
-- the following retrieves the data in employee_id, last_name, first_name columns -- and provides column aliases for more descriptive headings of the columns SELECT employee_id "Employee ID number", last_name "Employee last name", first_name "Employee first name" FROM employees;