I have a table emp , Fields with empname,dnname,dno,salary.
now I want copy distinct salary with all emp detail from emp into new table which is not already exist in database. how would I do this ?

Answer Posted / b.kumar

WITH CTE
AS
(
SELECT *, ROW_NUMBER() OVER (PARTITION BY SAL ORDER BY SAL) AS ROWID
FROM EMP7
) SELECT * INTO EMP10 FROM CTE WHERE ROWID=1

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is collation sensitivity? Explain different types.

721


What is clustered vs nonclustered index?

687


How to backup SQL Server Reporting Services ?

122


How to create a user name in a database?

771


Can a trigger be created on a view?

736






What is SubQuery in SQL Server 2008

714


What is SQL Azure Data sync?

115


Where do you find the default Index fill factor and how to change it?

792


What is a partition function in sql server?

701


Name few endpoints exposed by ssrs 2012?

330


Explain the concept of view and Types of views in SQL server?

774


Describe triggers features and limitations?

679


How does stuff differ from the replace function?

738


how to trace the traffic hitting a sql server? : Sql server database administration

1419


How do I start sql server?

698