Author

Author- Ram Ranjeet Kumar

Sunday, October 2, 2022

SQL Interview Question On GROUP BY AND HAVING CLAUSE

SQL QUESTIONS ON GROUP BY AND HAVING CLAUSE 

1. WRITE A QUERY TO DISPLAY TOTAL SALARY NEEDED TO PAY EACH JOB IN EMPLOYEE TABLE. 

2. WRITE A QUERY TO DISPLAY THE HIRE DATE ON WHICH AT LEAST 3 EMPLOYEES WHERE HIRED. 

3. WRITE A QUERY TO DISPLAY THE DEPARTMENT NUMBER WHICH HAS MORE THAN 2 EMPLOYEES AND THE TOTAL AMOUNT REQUIRED TO PAY THE MONTHLY SALARIES OF ALL THE EMPLOYEES IN THAT DEPARTMENT SHOULD BE MORE THAN 9000. 

4. WRITE A QUERY TO DISPLAY NUMBER OF EMPLOYEES WORKING IN EACH DEPARTMENT AND ITS’ AVERAGE SALARY BY EXCLUDING ALL THE EMPLOYEES WHOSE SALARY IS LESS THAN THEIR COMMISSION. 

5. WRITE A QUERY TO DISPLAY THE SALARIES WHICH HAS REPETITIONS IN THE SAL COLUMN OF EMPLOYEE TABLE. 

6. WRITE A QUERY TO DISPLAY THE EMPLOYEE NAME ONLY IF MORE THAN ONE PERSON IN THE EMPLOYEES OF THE COMPANY HAS SAME NAME. 

7. WRITE A QUERY TO DISPLAY THE DEPARTMENT NUMBER WHOSE AVERAGE SALARY IS BETWEEN 2500 AND 3000. 

8. WRITE A QUERY TO DISPLAY THE NUMBER OF EMPLOYEES ONLY IF THEY ARE WORKING AS MANAGER OR ANALYST AND THEIR ANNUAL SAL SHOULD END WITH A ZERO, IN EACH DEPARTMENT. 

9. WRITE A QUERY TO DISPLAY NO OF CLERKS WORKING IN EACH DEPARTMENT. 

10. WRITE A QUERY TO DISPLAY HIGHEST SALARY GIVEN TO A MANAGER IN EACH DEPARTMENT. 

11. WRITE A QUERY TO DISPLAY NO OF TIMES THE SALARIES HAVE REPEATED IN THE EMP TABLE. 

12.WRITE A QUERY TO DISPLAY DEPTNO AND MUNBER OF EMPLOYEES 

WHORKING IN EACH DEPARTMENT EXCEPT FOR THOSE WORKING IN DEPT 

10 

13.WAQTD NUMBER OF EMPLOYEES GETTING COMISSION IN EACH 

DEPARTMENT 

14.WAQTD NUMBER OF EMPLOYEES GETTING SALARY MORE THAN 1600 

EXCLUDING ALL THE MANAGERS IN EACH DEPARTEMNT  

15.WAQTD AVERAGE SALARY NEEDED TO PAY ALL THE EMPLOYEES WHO ARE HAVING A REPORTING MANAGER IN EACH JOB . 

16.WAQTD NUMBER OF EMPLOYEES HIRED INTO THE SAME DEPARTMENT ON THE SAME DAY 

17.WAQTD NUMBER OF EMPLOYEES GETTING THE SAME SALARY , 

WORKING IN THE SAME DEPARTMENT  

18.WAQTD MAXIMUM SALARY GIVEN IN EACH DESIGNATION EXCLUDING 

THOSE WHOS NAME STARTS WITH ‘K’ 

19.WAQTD NUMBER OF EMPLOYEES REPORTING TO 7839 IN EACH DEPT 

20.WAQTD NUMBER OF EMPLOYEE NAMES STARTING WITH AN VOWEL IN 

EACH DEPARTMENT  

 


No comments:

Post a Comment