MSSQL results match your MySQL and PostgreSQL results. (I only changed the table name to be a temporary table)
create table #t1(a INT, b INT, c INT); insert into #t1 values(1, 2, 4); insert into #t1 values(2, -1000, 5); (1 row(s) affected) (1 row(s) affected) -- See if select alias or table column has precedence in ORDER BY select a, a+b AS c from #t1 order by c; a c ----------- ----------- 2 -998 1 3 (2 row(s) affected) -- See if aliases accepted in UNION/ORDER BY combination select a AS foo from #t1 union select b from #t1 order by foo; foo ----------- -1000 1 2 (3 row(s) affected) -- See if ambiguous column aliases, UNIONs and ORDER BY work together select a, a+b AS c from #t1 UNION ALL select a AS c, c AS a from #t1 order by c; a c ----------- ----------- 2 -998 1 3 1 4 2 5 (4 row(s) affected) select @@version Microsoft SQL Server 2005 - 9.00.2050.00 (Intel X86) Feb 13 2007 23:02:48 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1) ------------------------------------------- We're Hiring! Seeking a passionate developer to join our team building Flex based products. Position is in the Washington D.C. metro area. If interested contact [EMAIL PROTECTED] ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------