Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

i have a table student like
sname
-----
ram
ram
ram
raj
raj
raj
i need the output like
sname
-----
ram
raj
ram
raj
ram
raj

Answer Posted / sagun sawant

;with TEST as (select Row_Number() over (partition by sname
order by sname) as ROWNO,sname from student)
select sname from TEST order by ROWNO,(case when sname
= 'RAM' then 1
when sname = 'RAJ' then 2 end)

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are sql servers used for?

1053


How would you go about developing a ssrs report?

174


how can you check the level of fragmentation on a table? : Sql server administration

990


How to select some specific rows from a table in ms sql server?

1010


Explain few examples of RDBMS?

1047


What is the difference between functions and scalar functions?

1217


How to transfer data from a cursor to variables with a "fetch" statement?

1105


How is sql used in sql server?

1019


what is nonclustered index

966


What are the differences between user defined functions and stored procedures?

1079


What is tabulation?

956


How to create a simple table to test triggers in ms sql server?

984


What are the properties of the transaction?

1008


what are the critical issues you have resloved in your company

1966


What is the difference between truncate and delete commands?

1075