Hello All Developeres,

Please Read Below Senario.
I have one table Supposed "Emp(EmpID,EmpName)"
Now There is data with Name "testName1" and "testName2" in EmpName Field

Now I need query which fetch all record in asceding order for EmpName Field
and Record with "testName1" and "testName2" will must display at last.

Please Wait for your reply.....
Thanks....
Pari13...

select EmpID,EmpName from Emp a group by a.EmpID,a.EmpName
union
select EmpID,EmpName from Emp a group by a.EmpID,a.EmpName order by EmpName

hi i think this query solve your problem

try this

select EmpID,EmpName from Emp order by EmpName

Since you want 2 particular names to go last, I assume you know how to sort the results, but want the whole field sorted ascending and out of sort those 2 names in the bottom.
I'll give you an example for 2 names hardcoded and you can modify it with params or with another table or whatever.

select EmpID,EmpName from Emp 
order by case when EmpName in ('testName1','testName2') then 2 else 1 end,EmpName
commented: you got it +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.