how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / gaurav singh 'viccky'
select salary from user=(select max(salary)from user where
salary < (select max(salary)from user))
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / arjunraj
aa means table-alias name
bb means table-alisa name
select * from emp aa where 2=(select count(distinct empsalary) from emp bb where aa.empsalary<=bb.empsalary)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / dakshin
select * from (select a.*,dense_rank() over (order by sal) rnk from emp a order by sal) where rnk =2
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kishor dange
select max(sal) from table_name where sal<(select max(sal)
from table_name)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vikas
select top 1 salary from emp
where salary in (select top 2 salary from emp order by salary desc)order by salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashwini
select max(salary) from employee where salary < (select max(salary) from employee)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manjusha
select * from emp e1
where 2=(select count(distinct salary) from emp e2
where e1.sal<e2.sal);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hari thorat
select max(salary) from employee where salary <(select max(salary) from employee);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / gunjal ghagre
Select sal from table_name order by sal desc limit 1,1;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / debasish
select ename,sal from (select ename,sal,row_number()
over(order by sal desc)rn from emp)
where rn=1;
| Is This Answer Correct ? | 0 Yes | 0 No |
How can multiply values of a column? OR How can multiply value of a row of a column using a single query in SQL?
Difference between aggregate function and analytical function?
i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output. trans_id trans_amt debit_credit_indicator i want get highest credit amount and lowest credit amount and highest debit amount and lowest debit amount for each trans_id. pls give me answer. i want urgent
Differentiate between pl/sql and sql?
what are the differences between get and post methods in form submitting. Give the case where we can use get and we can use post methods? : Sql dba
How to write a single statement that concatenates the words ?hello? And ?world? And assign it in a variable named greeting?
Can we create table inside stored procedure?
How show all rows in sql?
Why we use triggers in mysql?
What are the different types of database management systems?
What is ROWID?
Explain the advantages and disadvantages of stored procedure?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)