0

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...

4
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by adam_k
0

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

Edited by prit005: n/a

1

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

Edited by adam_k: n/a

Votes + Comments
you got it
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.