I have the following test-code:
CREATE TABLE #Foo (Foo int)
INSERT INTO #Foo SELECT 4
INSERT INTO #Foo SELECT NULL
INSERT INTO #Foo SELECT 2
INSERT INTO #Foo SELECT 5
INSERT INTO #Foo SELECT 1
SELECT * FROM #Foo
ORDER BY
CASE WHEN Foo IS NULL THEN Foo DESC ELSE Foo END
DROP TABLE #Foo
I'm trying to produce the following output:
1
2
3
4
5
NULL
"If null then put it last"
How is that done using Sql 2005
/M
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…