• sushantkatte (8/1/2015)


    Thank You very much @SScrazy for providing the solution. i am very new to the sql server programming and have started learning recently. could you please help me understand the logic of script that you provided and how it works?

    Actually this question was asked to me in an interview

    did you get the job?

    anyways...I am assuming that you understand 'ORDER BY' and that its the 'CASE' expression that you are unfamiliar with.

    I suggest that you read the following....this will explain in far better detail than I can.

    https://technet.microsoft.com/en-us/library/ms181765(v=sql.105).aspx

    also...as @LinksUp suggested, you can consider other solutions.....maybe a new table to store sort orders or add an additional column to an exg table.

    it all depends.....without more detail on your actual tables it cannot be readily answered

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day