SQL tutorial •
Lesson
10
,
Creating Columns

Creating a new column and naming it AS something

Apart from selecting columns from the existing data, it’s also very simple to create new columns. For example, you might want to highlight in the Customer table that each row is a customer. You can simply add this in a new column to the table like this:

It will look like this:

If you have a look at the query, you can see that the way to add a new column is quite simple. You start by defining what the content of this column should be — in this case simply the word <span class="code">'Customer'</span>. Use single quotation marks to indicate that this is a word you want to add to the table. This is followed by a statement to name the columns, written with the statement <span class="code">AS</span> followed by the name of the column. It’s best practice to avoid spaces in the column names, so you would typically replace these with an underscore <span class="code">_</span>. You can always rename your column names later on in your visualization tool if you want them to look nicer to read.

Next up:
Making calculations in columns