One way is to sort it like this:
ORDER BY
(CASE WHEN Foo IS NULL THEN 1 ELSE 0 END), Foo
Or: First sort by null, then sort by the Foo contents.
More Related Contents:
- Insert an image in a column of a table that already has 5 columns
- Get top 1 row of each group
- Referring to a Column Alias in a WHERE Clause
- How to SELECT FROM stored procedure
- Convert Month Number to Month Name Function in SQL
- How to avoid the “divide by zero” error in SQL?
- SET versus SELECT when assigning variables?
- Is there any difference between IS NULL and =NULL
- Generate a resultset of incrementing dates in TSQL
- Real life example, when to use OUTER / CROSS APPLY in SQL
- Getting result of dynamic SQL into a variable for sql-server
- How to get difference between two rows for a column field?
- Better techniques for trimming leading zeros in SQL Server?
- How to print VARCHAR(MAX) using Print Statement?
- SQL statement to select all rows from previous day
- What’s the best way to select the minimum value from several columns?
- Splitting delimited values in a SQL column into multiple rows
- SQL : in clause in stored procedure:how to pass values
- How to insert a blob into a database using sql server management studio
- SQL GROUP BY CASE statement with aggregate function
- separate comma separated values and store in table in sql server
- Best way to do nested case statement logic in SQL Server
- How to check which locks are held on a table
- Execution sequence of Group By, Having and Where clause in SQL Server?
- SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE
- Is it possible to execute a text file from SQL query?
- Add a row number to result set of a SQL query
- How can I find Unicode/non-ASCII characters in an NTEXT field in a SQL Server 2005 table?
- Sql Server : How to use an aggregate function like MAX in a WHERE clause
- Hierarchical Queries in SQL Server 2005