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 / murthy

select e.name from
(select *,row_number() over (partition by name order by
name) as Rw from #T1) e
order by e.Rw,name desc

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to join two tables in a single query in ms sql server?

718


explain different types of backups avaialabe in sql server? : Sql server database administration

754


What are trace flags and mention a few common trace flags used with sql server?

749


How to get a list of table columns using the "sp_columns" stored procedure in ms sql server?

741


What are the dmvs?

769






What is the main purpose of having conversation group?

663


you have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem? : Sql server administration

735


What is the order by used for?

792


What is a system database and what is a user database?

768


What are different replication agents and what's their purpose? : sql server replication

743


What are the requirements on sql server network connections?

692


Write a sql query to display the current date?

826


What does the on delete cascade option do?

747


How do you improve the performance of a SQL Azure Database?

129


Do you know what guidelines should be followed to help minimize deadlocks?

722