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 is the maximum size of a row in sql server?

710


Will sql server 2005 allow you to reduce the size of a column?

702


What are the lambda triggers?

654


Explain differences between web edition and business edition?

115


What is Transparent Data Encryption?

731






What is PROJECTION Operation?

767


How to download and install the scaled-down database adventureworkslt?

778


What are the restraints imposed on the table design by a merge replication?

789


What is parameterized reports in ssrs ?

125


What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.

2530


What is the name of reporting services config file and what’s it’s used for?

119


How to drop existing views from a database in ms sql server?

736


Can you use order by when defining a view?

730


How to execute a stored procedure in ms sql server?

733


How to get the definition of a user defined function back?

805