BLOGS BY TOPIC
BLOGS BY AUTHOR
BLOGS BY YEAR
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:
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!