write a query to find out the no. of employees whose age is
less than 25 and max of salary for the employees belonging
to a particular department is less than 20000
Answers were Sorted based on User's Feedback
Answer / khushbu patel
select dept,count(emp),max(sal)
from a
where age < 25
group by dept
having max(sal) < 20000
| Is This Answer Correct ? | 11 Yes | 2 No |
Answer / vikneswaran thangarasu
Ignore my previous post. it is wrong.
select dept,count(emp),max(sal) from employee where age <25
group by dept having max(sal) <20000
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / priya
select dept,count(emp) from employee where age <25 and max
(sal) <20000 group by dept.
| Is This Answer Correct ? | 4 Yes | 4 No |
Answer / vikneswaran thangarasu
select dept,count(emp),max(sal) from employee where age <25
and sal <20000 group by dept
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / pradeep
There is little mistake in Nitin the MONTHS_BETWEEN
(SYSDATE,hiredate)should be stated like this because if we
place hiredate firt the output comes in Negative, so it
gives all record.
select DEPTno,COUNT(EMPno),max(SAL)
from EMP
where (TO_CHAR(sysdate,'yyyy') - TO_CHAR(HIREDATE,'yyyy'))
< 25
GROUP BY DEPTno
having max(sal) < 20000
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / nitin umale
SELECT department_id, COUNT(employee_id), MAX(salary)
FROM employees
WHERE MONTHS_BETWEEN(hire_date, SYSDATE) < 25*12
GROUP BY department_id
HAVING MAX(salary) < 20000;
| Is This Answer Correct ? | 3 Yes | 6 No |
What are the advantages of pl sql?
What is the difference between local and global temporary table?
Is pl sql a scripting language?
What language is oracle sql developer?
How will you make performance better for application including front end and back
What is a primary key, and how is it different from a unique key?
What is an Exception ? What are types of Exception ?
How do you write an inner join query?
What is the difference between inner join and natural join?
What is #table in sql?
How do I install microsoft sql?
Can we use ddl statements in 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)