Learn SQL/Beginner/SQL Foundations/SQL Column Aliases (AS)

SQL Column Aliases (AS)

Rename a column in the output only — the underlying table is never touched.

What & Why

AS renames a column (or a computed expression) in the query's result, without changing anything about the real table. It's purely cosmetic for the output you see.

See How It Works

idnamechannelspendstart_dateend_datestatustarget_segment
1Spring Launchgoogle_ads55000.002024-01-152024-03-31activesmb
2Retention Webinaremail45000.002024-02-102024-04-15activeenterprise
3Finance Retargetinglinkedin50000.002024-03-122024-05-31activeenterprise
4Enterprise Searchgoogle_ads60000.002024-04-012024-06-30activeenterprise
EXAMPLE QUERY
SELECT name AS campaign_name, spend AS campaign_spend
FROM marketing.campaigns;
RESULT — column names changed, data didn't
campaign_namecampaign_spend
Spring Launch55000.00
Retention Webinar45000.00
Finance Retargeting50000.00
Enterprise Search60000.00

The result uses the same Queryflo columns shown in the worked example.

Now You Try

Practice this concept

Marketing wants campaign names and spend values returned with report-friendly column aliases.

Available schema
marketing

Prefix tables with marketing.table_name.

campaign_namecampaign_spend
marketing.campaigns
ColumnType
idinteger
nametext
channeltext
spendnumeric
start_datedate
end_datedate
statustext
target_segmenttext
legacy_idtext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario