adspace


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

What are the kinds of subquery?

1111


Where can you add custom error messages to sql server?

1216


What are different types of constraints?

1004


What is the primary use of the model database?

1151


What is an indexed view?

1023


Explain system functions or built-in functions? What are different types of system functions?

1067


How to convert numeric expression data types using the cast() function?

1152


How to enter binary string literals in ms sql server?

1247


Can one drop a column from a table?

1092


How to connect php with different port numbers?

1192


What is self contained sub query?

1141


do you know how to configure db2 side of the application? : Sql server database administration

1125


Disadvantages of the indexes?

1226


what is the difference between openrowset and openquery?

1198


How to provide default values to function parameters?

1262