Home Forums SQL Server 2008 T-SQL (SS2K8) Using Results from one column to calculate another column RE: Using Results from one column to calculate another column

  • CELKO (1/4/2013)

    Think about what a confused mess this statement is in the SQL model.

    SELECT f(c2) AS c1, f(c1) AS c2 FROM Foobar;

    That is why such nonsense is illegal syntax.

    Your claim is nonsense. I don't see what's illegal about that general syntax in SQL Server, viz:

    SELECT RTRIM(c2) AS c1, RTRIM(c1) AS c2

    FROM (

    SELECT 'Y' AS c1, 'Z' AS c2 UNION ALL

    SELECT 'C' AS c1, 'D' AS c2 UNION ALL

    SELECT 'A' AS c1, 'B' AS c2

    ) AS test_data

    ORDER BY c1

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.