Skip to content
Advertisement

NULL Values at Bottom of SQL Table – SQL Server 2000

I have a table with information containing names and emails. I have to put the rows containing NULL email values at the bottom of the table, but am unable to when I use the SELECT DISTINCT clause. Here is my current syntax:

but whenever I try to execute this query, I receive the error message:

This query works if I take out the DISTINCT clause, but it is necessary in this case. Any tips?

Advertisement

Answer

Use aggregation instead:

This is functionally the same as your question. However, the SQL engine will not get confused about an expression that uses a distinct column.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement