January 13, 2011 at 3:07 am
Hi Experts,
I want reuslt something like,
suppose there is sql query which returns employee names in employee table.
I am passing employee name to that query. i want to show this passed employee name on the first row and then other rows.
for ex. i am passing 'ron' then result set should like this..
ron
tango
danny
amo
Please help me..
Thanks in advace.
January 13, 2011 at 7:17 am
declare @table table(id int ,name varchar(50))
insert into @table
select 1,'ron'
union
select 2,'tango'
union
select 3,'danny'
union
select 4,'amo'
declare @param varchar(50) = 'tango'
select id,name from
(
select
* ,
case when name = @param then 1 else 0 end as customSort
from
@table
)x
order by customSort desc
like this?
January 13, 2011 at 7:36 am
Thank you sir. I want like this. Thank you very much.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply