这是有效的 ANSI SQL 吗?:
SELECT 1 AS X
,2 * X AS Y
,3 * Y AS Z
因为 Teradata (12) 可以做到这一点,也可以做到这一点(是的,不是很疯狂):
SELECT 3 * Y AS Z
,2 * X AS Y
,1 AS X
但是 SQL Server 2005 需要这样的东西:
SELECT X
,Y
,3 * Y AS Z
FROM (
SELECT X
,2 * X AS Y
FROM (
SELECT 1 AS X
) AS X
) AS Y