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 is a common use of group by in sql?
What is the least restrictive isolation level? : Transact sql
What are the different datatypes available in PL/SQL?
How can I tell if sql is running?
i want count no of values in a column i.e enam eempno phoneno x 1 (98765,09887,096561,87964579,156678,678900876) that means if i select phone no from table i want to get total count of phone numbers i.e 6
What is mutating trigger?
The select into statement is most often used to create backup copies of tables or for archiving records?
What is sql engine in oracle?
What is foreign key and example?
What is the difference between delete and truncate statement in sql?
Is truncate ddl or dml?
How do I quit sql?