0% found this document useful (0 votes)
38 views1 page

SQL Queries for Employee Salary Analysis

The document contains a series of SQL queries that retrieve various employee and department data based on specific conditions, such as salary comparisons and department affiliations. Each query utilizes subqueries to filter results, demonstrating the use of aggregate functions and conditional logic in SQL. The examples illustrate different ways to access and manipulate employee records within a database.

Uploaded by

Fawad Amazon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

SQL Queries for Employee Salary Analysis

The document contains a series of SQL queries that retrieve various employee and department data based on specific conditions, such as salary comparisons and department affiliations. Each query utilizes subqueries to filter results, demonstrating the use of aggregate functions and conditional logic in SQL. The examples illustrate different ways to access and manipulate employee records within a database.

Uploaded by

Fawad Amazon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1.

select * from employees where salary <Any (select salary from employees where
department_id in (50,20,10));
[Link] employee_id,last_name from employees where department_id=any(select
department_id from employees where last_name like '%a%u%');
[Link] last_name,department_id,job_id from employees where department_id =any
(select department_id from departments where location_id=1700);
[Link] job_id,job_title from jobs where max_salary>(select max_salary from jobs
where job_id='ST_MAN');
[Link] employee_id,first_name,salary from employees where salary> (select
avg(salary) from employees) order by salary;
[Link] * from departments where department_id in(select department_id from
employees having min(salary)>(select min(salary) from employees where
department_id=50)group by department_id);
EXAMPLES:
[Link] last_name, salary FROM employees where salary > (select salary from
employees where last_name = 'Jones');
[Link] first_name,job_id from employees where job_id=(select job_id from
employees where employee_id=177);
[Link] * from employees where job_id = (select job_id from employees where
employee_id=143) and salary>(select salary from employees where employee_id=143) ;
[Link] employee_id, last_name, job_id, salary from employees where salary < ANY
(SELECT salary from employees where job_id = 'IT_PROG');
[Link] employee_id, last_name, job_id, salary from employees where salary < ALL
(SELECT salary from employees where job_id = 'IT_PROG');
[Link] last_name, job_id, salary FROM employees WHERE salary = (SELECT
MIN(salary) FROM employees);
[Link] department_id, MIN(salary) FROM Employees GROUP BY department_id HAVING
MIN (salary)>(SELECT MIN (salary) FROM employees WHERE department_id=20);

You might also like