HOW CAN I FIND MAX SAL ,ENAME FROM EMP TABLE.
Answers were Sorted based on User's Feedback
Answer / kanhu charan biswal
select ename, sal from emp where sal=(select max(sal) from
emp);
For see the max(sal) with ename departmentwise the query
will be:
select ename,sal from emp a
where sal in (select max(sal) from emp group by deptno);
For findout the nth highest salary with name, the query
will be:
select ename,sal from emp a
where &n=(select count(distinct sal) from emp b
where b.sal>=a.sal)
after execute the query it will ask you to pass a value
for 'n'.it stands for nth hiest salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / binod singh
SELECT max(Distinct sal),ename
FROM emp
/
SQL> select max(distinct salary) from employees;
MAX(DISTINCTSALARY)
-------------------
24000
| Is This Answer Correct ? | 3 Yes | 5 No |
Answer / ahmad nazmi
select ename , max(sal)
from emp
group by ename;
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / madhav
select ename from emp where sal=(select max(sal) from emp);
ENAME
---------
KING
--first execute the inner query like
select max(sal) from emp;
MAX(SAL)
---------
5000
--- after that salary value pass the outer query like
this
select ename from emp where sal=5000
ENAME
---------
KING
Email:thota.madhav@gmail.com
| Is This Answer Correct ? | 2 Yes | 6 No |
Answer / suresh kumar somayajula
SELECT ename,MAX(sal)
FROM EMP
GROUP BY ename;
| Is This Answer Correct ? | 9 Yes | 15 No |
Answer / ahmad nazmi
select ename , max(sal)
from emp
group by ename ;
| Is This Answer Correct ? | 4 Yes | 11 No |
What is the difference between sql and isql*plus?
What is a common use of group by in sql?
Which one is faster ienumerable or iqueryable?
What is sql table?
Why do we need a foreign key?
how to create a table index in mysql? : Sql dba
What is a full join sql?
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
what is dbms? : Sql dba
What is data profiling in sql?
How do you use a while loop in pl sql?
What are the two types of cursors in pl sql?
Oracle (3253)
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)