[Solved] Retrieve Last Row from a table using Max or top or rowset


I guess you can use MAX(MID(Emp_ID, 1)) in place of MAX(Emp_ID).

If it still does not work, converting string to number should help.
Example – MAX(TO_NUMBER(MID(Emp_ID, 1))).

Edit –
First of all, there is no use for order by. And since you asked for SQL server, use this –

SELECT 'E00' + CAST (MAX (CONVERT (INT, RIGHT(Emp_ID, LEN(Emp_ID) - 1))) AS varchar) from Emp_Id;

5

solved Retrieve Last Row from a table using Max or top or rowset