Weld logo
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:

2    id
3  , first_name
4  , last_name
5  , email
6  , phone
7  , updated_at
8  , 'Customer' as status
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.

Next up

Making calculations in columns

Go to lesson
Weld logo

Tired of scattered data? Sync your data in minutes with Weld. Connect to 150+ apps, files and databases.

Backed by leading investors
Frontline logoCherry logoInnnovation Fund logo
Twitter LogoLinkedIn Logo
© 2024 Weld. All rights reserved.