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
Question
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
Solution
To answer your queries, we will use SQL (Structured Query Language), which is a standard language for managing data held in a relational database management system.
- To find the employees who get a salary more than Chris, we first need to find out how much Chris earns. Then we compare this salary with the salaries of all other employees. Here is the SQL query for this:
SELECT empno, ename, salary
FROM EMP
WHERE salary > (SELECT salary FROM EMP WHERE ename = 'Chris');
This query first finds the salary of Chris, then selects the employee number, name, and salary of all employees whose salary is greater than Chris's salary.
- To display the department number along with the number of employees which belongs to that department number, we can use the GROUP BY clause in SQL. Here is the SQL query for this:
SELECT deptno, COUNT(empno) as num_of_employees
FROM EMP
GROUP BY deptno;
This query groups the employees by their department number, then counts the number of employees in each department. The result is a list of department numbers along with the number of employees in each department.
Similar Questions
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
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
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
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
Find the following table EmployeeDetails, with the attributes EmployeeID, EmpName, Designation, Salary, DeptNo. You are assigned to a task of providing the solution to the operations department by writing the query which displays the employeeID and the Designation of all the employees whose Salaries are more than the Salary of employees designated as ManagerC
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.