Knowee
Questions
Features
Study Tools

we have following relations:employees(emp_id,name,dept_id)salaries (emp_id,salary)1) Find out the names of employees who belong to the same department as Mark andsalary greater than 50,000.2) Find out names of employees whose salaries are greater than 50,000.3) Retrieve the names of employees who have higher salary then John

Question

we have following relations:employees(emp_id,name,dept_id)salaries (emp_id,salary)1) Find out the names of employees who belong to the same department as Mark andsalary greater than 50,000.2) Find out names of employees whose salaries are greater than 50,000.3) Retrieve the names of employees who have higher salary then John

🧐 Not the exact question you are looking for?Go ask a question

Solution

  1. To find out the names of employees who belong to the same department as Mark and have a salary greater than 50,000, you would need to perform a join operation on the two tables based on the emp_id, and then filter based on the conditions. Here is the SQL query:
SELECT e.name
FROM employees e
JOIN salaries s ON e.emp_id = s.emp_id
WHERE e.dept_id = (SELECT dept_id FROM employees WHERE name = 'Mark') 
AND s.salary > 50000;
  1. To find out names of employees whose salaries are greater than 50,000, you would need to join the two tables and filter where the salary is greater than 50,000. Here is the SQL query:
SELECT e.name
FROM employees e
JOIN salaries s ON e.emp_id = s.emp_id
WHERE s.salary > 50000;
  1. To retrieve the names of employees who have a higher salary than John, you would need to join the two tables and filter where the salary is greater than John's salary. Here is the SQL query:
SELECT e.name
FROM employees e
JOIN salaries s ON e.emp_id = s.emp_id
WHERE s.salary > (SELECT s.salary FROM salaries s JOIN employees e ON e.emp_id = s.emp_id WHERE e.name = 'John');

This problem has been solved

Similar Questions

We have following relations:employees(emp_id, first_name, last_name, email, salary, dept_id)departments(dept_id, dept_name, location_id)(1) Find the employee who is getting second highest salary.(2) Display all the employee name along with department name who are working neitherin ‘Marketing’ Department nor earns more than 75000

we have following relationsEMP(empno, ename, jobtitle, manager, hiredate, salary, deptno)DEPT(deptno, dname,location)Answer the following queries .1) Find the Employees who get salary more than Chris salary.2) Display department number along with the number of employees which belongs to thatdepartment number

We have following relationEMP(empo,ename,jobtitle,manager_no,hiredate,salary,deptno)DEPT (deptno, dname,location)1) Find employees whose name start with letter A or letter a.2) Find the employees who are working in smith's department.3) Display employees who are getting maximum salary in each department

For given relation:Employee(eid, ename, address,deptname ,salary)Project(eid, pid, pname, location)(1) Display name and salary of employee who is taking maximum salary.(2) Display highest salary department wise and name of employee who is taking thatsalary.(3) Find details of employee who works on a pid equal to 10

Write a query to display the ename of employees working in 'HR' department and who draw an annual salary greater than 1000000. [Consider employees who work in multiple departments too]. Display the records sorted in ascending order based on employee ename.Note:1. Display all the ename of employees working in 'HR' department and having annual salary greater than 1000000.2. Use Joins. Tables involved are employee, works and department3. Order by is mandatory.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.