WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 525 reviews for our classroom and online training
A short blog listing many ways to create aliases for columns in SQL
It's not often that this owl learns new things about SQL when giving a course, but when I do, I like to share my new knowledge! This blog shows a new way to create aliases for columns in SQL.

Posted by Andy Brown on 01 February 2016

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

A different way to do column aliases

It's never too old to teach an old dog new tricks.  Thanks to Chepren from a recent course for showing me this different approach to creating column aliases.

The traditional method

My colleague Andy Gould has already blogged about using column aliases.  There are basically 3 ways, as shown in this query:


-- alias using quote marks

FilmName as 'Name of film',

-- if you don't have any spaces, you can

-- use the alias name without punctuation

FilmOscarWins as Oscars,

-- alternatively, you can use square brackets

FilmRunTimeMinutes as [Film Length]



This would give your 3 columns these names:

Renamed columns

The output from the query above might look like this.


Note that you can omit the word AS from each line of the query above, although this owl thinks it's much clearer if you include it!

The "new" method

You can, however, also put the column alias at the start of each line of the SELECT statement:


-- the other way ...

'Name of film' = FilmName,

Oscars = FilmOscarWins,

[Film Length] = FilmRunTimeMinutes



Is this better?  Probably not, but it's certainly different, and I was so stunned to discover it was possible that I thought I'd share it!

This blog has 0 threads Add post