adspace


Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500

Output should be

A 200
B 300
C 400
D 500

Answer Posted / gaurav sharma

SELECT DISTINCT * INTO Employee1 FROM Employee
DROP Table Employee
sp_rename 'Employee1','Employee'

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why and when do stored procedure recompile?

1060


This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?

2567


What are the properties of the transaction?

1073


How can we solve concurrency problems?

1122


What are different types of constraints?

1001


What is clustered index

1086


How efficient you are in oracle and SQL server?

1257


What are the different SQL Server Versions you have worked on?

1079


what is spatial nonclustered index

1058


Why should you use or avoid select * statements?

1109


Equi join and non equi join is possible with sql server?

1134


When should you use an instead of trigger?

1052


What are wait types?

1249


What are the different subsets of sql?

1652


Can we shrink data file in sql server?

1128