ORDER BY alias

  • Comments posted to this topic are about the item ORDER BY alias

  • The correct answer is "none of them".

    The query below generates an error: "Ambiguous column name", because "val" is both an alias and a column name:

    SELECT id, ISNULL(val, id) + 1 val

    FROM tmp_tab

    ORDER BY val;    -- orders by alias "val"

    The other "ORDER BY":

    new_val+1 generates an error: "new_val" is not a column name

    val+1 => Ambiguous column name

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply