w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display the job ID for those jobs which average salary is above 8000

SQL SORTING and FILTERING on HR Database: Exercise-34 with Solution

34. Write a query in SQL to display the job ID for those jobs which average salary is above 8000.

Sample table : employees


Sample Solution:

SELECT job_id, AVG(salary) 
     FROM employees 
         GROUP BY job_id 
               HAVING AVG(salary)>8000;

Sample Output:

   job_id   |          avg
------------+------------------------
 AC_ACCOUNT |  8300.0000000000000000
 SA_MAN     |     12200.000000000000
 AD_PRES    |     24000.000000000000
 AC_MGR     | 12000.0000000000000000
 FI_MGR     | 12000.0000000000000000
 MK_MAN     | 13000.0000000000000000
 PR_REP     | 10000.0000000000000000
 AD_VP      |     17000.000000000000
 SA_REP     |  8350.0000000000000000
 PU_MAN     | 11000.0000000000000000
(10 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the job ID for those jobs which average salary is above 8000 - Duration

Rows:

Query visualization of Display the job ID for those jobs which average salary is above 8000 - Rows

Cost:

Query visualization of Display the job ID for those jobs which average salary is above 8000 - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display the details of the employees who have no commission percentage and salary within the range 7000 to 12000 and works in that department which number is 50.
Next: Write a query in SQL to display job Title, the difference between minimum and maximum salaries for those jobs which max salary within the range 12000 to 18000.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming