Query to select record sorted by last name

  • I have a table "Employee" with only one column "NAME".

    Entries are like

    "Ramesh Singh"

    "M Robert"

    "S Chand" ... and so on.

    Write a select statement to list completename -- sorted by Lastname (Singh,Robert,Chand)

  • SELECT *

    FROM Employees

    ORDER BY PARSENAME(REPLACE(Name, ' ', '.'), 1)


    N 56°04'39.16"
    E 12°55'05.25"

  • Thank you very much..its giving me desired result.:)

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

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