w3resource

SQL Exercise: Average salaries of the employees works as ANALYST

SQL employee Database: Exercise-13 with Solution

[An editor is available at the bottom of the page to write and execute the scripts.]

13. From the following table, write a SQL query to calculate the average salary of employees who work as analysts. Return average salary.

Sample table: employees


Pictorial Presentation:

SQL exercises on employee Database: Display the average salaries of all the employees who works as ANALYST.

Sample Solution:

SELECT avg(salary)
FROM employees
WHERE job_name = 'ANALYST';

Sample Output:

          avg
-----------------------
 3100.0000000000000000
(1 row)

Explanation:

The provided query in SQL that selects the average salary of all employees with the job title 'ANALYST' from the 'employees' table.

The "WHERE" clause filters the results of all employees with the job title 'ANALYST'.

Relational Algebra Expression:

Relational Algebra Expression: Display the average salaries of all the employees who works as ANALYST.

Relational Algebra Tree:

Relational Algebra Tree: Display the average salaries of all the employees who works as ANALYST.

Practice Online


Sample Database: employee

employee database structure

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: List the employees who joined before 1991.
Next SQL Exercise: Display the details of the employee BLAZE.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/sql-exercises/employee-database-exercise/sql-employee-database-exercise-13.php