Reputation: 3636
In a SELECT
statement like this...
SELECT DISTINCT NULL[Column1], NULL[Column2], Column2, etc...
FROM Table
What exactly are the NULL statements doing before the column names? This runs fine.
Upvotes: 0
Views: 60
Reputation: 1269923
The NULL
is the value. The column name is the name of the column.
I would write this as:
select distinct null as column1, . . ..
The as
makes it more clear that name is being given the value.
In SQL Server, you can also use:
select distinct column1 = null, . . .
I don't like this shorthand (because it is not supported by other databases and it looks too much like variable assignment). However, it is popular among some people.
Upvotes: 7