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 ?

Answers were Sorted based on User's Feedback



I have a table emp , Fields with empname,dnname,dno,salary. now I want copy distinct salary with all..

Answer / prashant

SELECT DISTINCT empname,dnname,dno,salary into New Table
from emp

Is This Answer Correct ?    3 Yes 2 No

I have a table emp , Fields with empname,dnname,dno,salary. now I want copy distinct salary with all..

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

More SQL Server Interview Questions

Where sql server user names and passwords are stored in sql server? : sql server database administration

0 Answers  


explain different types of cursors? : Sql server database administration

0 Answers  


What is CTE in SQL

0 Answers   Infosys,


Which table keeps information about stored procedures?

0 Answers  


What does the automatic recovery do?

0 Answers  






What is the difference between set and select?

0 Answers  


How do I create an extended event in sql server?

0 Answers  


How to convert a table data in XML format in sql server?

0 Answers  


Define indexes?

0 Answers  


Define self join?

0 Answers  


Write a query to delete duplicate records in SQL SERVER

36 Answers   Infosys,


What is a trigger?

7 Answers  


Categories