3 votes 3 votes Consider the set of relations EMP (Employee-no. Dept-no, Employee-name, Salary) DEPT (Dept-no. Dept-name, Location) Write an SQL query to: Calculate, for each department number, the number of employees with a salary greater than Rs. 1,00,000 Databases gate1999 databases sql descriptive easy + – go_editor asked Feb 8, 2018 go_editor 1.8k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
5 votes 5 votes SELECT Dept-no, count(Employee-no) as total_employees FROM EMP WHERE Salary > 100000 GROUP BY Dept-no balraj_allam answered Feb 13, 2018 balraj_allam comment Share Follow See all 2 Comments See all 2 2 Comments reply Pranavpurkar commented Aug 8, 2022 reply Follow Share i am getting something like this! SELECT COUNT(EMPLOYEE-NO),DEPT-NO FROM EMP e,DEPT d WHERE e.dept-no=d.dept-no HAVING SALARY > 100000 GROUP BY (DEPT-NO); pls check it once! 0 votes 0 votes rhl commented Jun 12, 2023 reply Follow Share @Pranavpurkar Having Clause can not come before Group By clause. 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes select Dept-no, count(*) from EMP group by Dept-no having salary > 100000 adeemajain answered Nov 20, 2019 adeemajain comment Share Follow See 1 comment See all 1 1 comment reply val_pro20 commented Oct 4, 2020 reply Follow Share I am also thinking the same. I think we Can also use having in group by 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes select Dept-no, count(Employee-no) from EMP where Salary>100000 group by Dept-no Mamta Satywali answered Feb 8, 2018 Mamta Satywali comment Share Follow See all 0 reply Please log in or register to add a comment.