1,693 views
1 votes
1 votes
emp(eid,ename,age,salary)
works(eid,did,pettime)
dept(did,dname,budget,managerid)

1.print the names and salary of each employee who works in more than on department.
2.for each department with 15 or more employees,print the department name and the number of employees that work in that department.
3.find the managers name and the department name that the manager manage the departments with budgets greater than $1.5million.
4.find the name and age of managers who manage the departments with the largest budgets,and list the related employees in the department.

1 Answer

1 votes
1 votes
Select ename,salary from emp where eid IN (select eid from works group by eid having count(eid) > 1);
select dname,count from dept natural join (select did,count(did) as count from works group by did having count(did) > 14) y;
select ename,dname from dept,emp where emp.eid = dept.did and budget>1500000;
select ename,age from emp where eid IN (select managerid from dept where budget >= (select max(budget) from dept ));

Related questions

0 votes
0 votes
1 answer
1
Reshu $ingh asked Jan 28, 2019
412 views
What are the parameters or procedure to follow to find out minimum no. of tables for given ER Diagram type of questions?
0 votes
0 votes
0 answers
2
Asutosh asked Jul 7, 2018
221 views
For the relations:A(pid, cid)B(pid, pname, powner)C(cid, cname, cdesciption)How will the query be executed :SELECT pname, cname FROM A, B, CWHERE B.powner = $somevalueAND...
0 votes
0 votes
0 answers
3
iarnav asked Dec 5, 2017
197 views
Kindly explain Check Constraint in SQL with a small example!