Column Aliases

Column Aliases

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.