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:
1select
2 id
3 , first_name
4 , last_name
5 , email
6 , phone
7 , updated_at
8 , 'Customer' as status
9from
10 {{raw.e_commerce_sample.webshop_customer}}
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 'Customer'. 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 AS 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 _. You can always rename your column names later on in your visualization tool if you want them to look nicer to read.