• Thanks Vinay for the question... 🙂

    I was not aware of the thing that if we use DISTINCT then Column names specified in the ORDER BY clause, must be defined in the select list.

    Learned some basic thing 😛

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/