1. How to fetch all the duplicate records from the table.

2. How to fetch the second highest salary from the table.

Answer Posted / rajkumar v

ANS 1:
select p.ColumnName from tablname p group by p.ColumnName

ans2:

Select min(salary)FROM emp WHERE (salary IN (SELECT
TOP 2 salary FROM emp ORDER BY salary DESC))
Or
Select top 1 salary from (select top 2 salary from emp
order by salary desc) emp order by salary

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why main is user defined function?

565


What is normalization process?

599


How do I find the size of a sql server database?

493


What is difference between join and natural join?

477


What is implicit cursors?

553






How to list all login names on the ms sql server?

535


Explain the Ways to improve the performance of a sql azure database?

64


Write a query for primary key constraint with identity key word?

575


Does order by actually change the order of the data in the tables or does it just change the output?

672


How to send a ssrs report from ssis?

125


What is difference statement and preparedstatement?

548


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

496


If user is owning any SQL Objects, can we drop that user

1605


What is 3nf normalization?

568


How can you find out which stored procedures are recompiling?

516