Basic SQL Topics
Performing Calculations on SQL Columns
Let’s rename several columns in SQL with the “AS” keyword.
SELECT City,
2022 estimate AS population2022,
2020 estimate AS population2020,
100 * (2022 estimate - 2020 estimate ) / (2020 estimate) AS percentChangeBetween2020and2022
FROM database_table
You can rename any column in SQL by adding the AS keyword and what you’d like to rename the column to above. The label “percentChangeBetween2020and2022” can also have been written “pctChange” or “pctChg” or anything you want.
This can make SQL columns much easier to deal with, and when exporting SQL data to Excel or to use in a calculation later, make your life easier if the column name is shorter, for example.