SQL: What does NULL as ColumnName imply

Shamim Hafiz picture Shamim Hafiz · Jun 28, 2013 · Viewed 37.9k times · Source

I understand that AS is used to create an alias. Therefore, it makes sense to have one long name aliased as a shorter one. However, I am seeing a SQL query NULL as ColumnName What does this imply?

SELECT *, NULL as aColumn

Answer

Aliasing can be used in a number of ways, not just to shorten a long column name.

In this case, your example means you're returning a column that always contains NULL, and it's alias/column name is aColumn.

Aliasing can also be used when you're using computed values, such as Column1 + Column2 AS Column3.