• Danny Ocean (7/14/2013)


    kapil_kk (7/14/2013)


    When I checked the BOL i found that there is a line stating:

    If a table name is aliased in the FROM clause, only the alias name can be used to qualify its columns in the ORDER BY clause.

    I did some modification in the query and try to run following scenarios and these all are working.

    select a ss from test t

    order by ss

    select t.a ss from test t

    order by a

    select a from test t

    order by a

    Can anyone tell me what does that BOL line means?

    According to BOl, If you have given a alias name to column name then you can not use column name in order by clause.

    the 2nd statement should give error like "invalid column name "a" ", but it doesn't. I am also looking for reason why 2nd T-sql code execute successfully.

    Thanks i got it... 🙂

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!