Column Aliases

Column Aliases

  • A column alias provides a way to create a clean or more descriptive header for a results set.
  • A column alias cannot be used in a SELECT, WHERE, GROUP BY or HAVING clause due to the order of execution. You must refer to the original column name.

In the previous example, we created a new column that was a calculated value. The problem is that the column header is now population / SurfaceArea. However, we can rename the column header to something cleaner by creating a column alias.  Look at the code snippet below.


SELECT name, population / SurfaceArea
     AS “People per square mile”
FROM country;

We used the AS keyword then in quotes we put the new column alias of “People per square mile.” Which changes the column header as seen show below.



CC BY-NC-ND International 4.0

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.

End-of-Chapter Survey

: How would you rate the overall quality of this chapter?
  1. Very Low Quality
  2. Low Quality
  3. Moderate Quality
  4. High Quality
  5. Very High Quality
Comments will be automatically submitted when you navigate away from the page.
Like this? Endorse it!