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

What command do we use to rename a database?

607


What is difference between after and before?

498


Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?

106


What is the difference in accessing db between sql server vs sql azure?

157


Explain the xml support sql server extends?

611






What are the difference between data mart and data warehouse? : sql server analysis services, ssas

498


What is 'Join' and explain its various types.

622


List the types of recovery model available in sql server?

501


Why is there a performance difference between two similar queries where one uses union and the other uses union all?

506


Can a database be shrunk with users active?

596


Benefits of Stored Procedures?

559


What is the difference between varchar and nvarchar datatypes?

569


How should i optimize the time for execution of stored procedure having single input and many output from the different tables?

1463


What are the basic functions for master, msdb, model, tempdb and resource databases?

547


How do you trace the traffic hitting a sql server?

614