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 / pradip jain

select sname from (select Row_Number() over (partition by
sname
order by sname) as ROWNO,sname from student) p
order by ROWNO,sname desc


only change table name same as bobby

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between line feed ( ) and carriage return ( )?

681


What is key attribute?

699


between cast and convert which function would you prefer and why?

727


Do you know the capabilities of cursors?

768


What are the differences between decimal and float in ms sql server?

749






What is standby servers? Explain types of standby servers.

675


How to use subqueries with the in operators in ms sql server?

747


How to modify an existing user defined function?

772


What are transactions in sql?

735


What is lookup override?

768


What is the security principal at the server level that represents your session?

780


Create and insert into temp table in sql server?

778


I have all the primary data files, secondary data files as well as logs. Now, tell me can I still restore the database without having a full backup? : sql server database administration

878


What are the instances when triggers are appropriate?

719


Is it possible to call a stored procedure within a stored procedure?

723