Knowee
Questions
Features
Study Tools

Suppose we wish to find the ID’s of the employees that are managed by people who are managed by the employee with ID 123. Here are two possible queries:I.SELECT ee.empIDFROM Emps ee, Emps ffWHERE ee.mgrID = ff.empID AND ff.mgrID = 123;II.SELECT empIDFROM Emps WHERE mgrID IN(SELECT empID FROM Emps WHERE mgrID = 123);Which, if any, of the two queries above will correctly (in SQL2) get the desired set of employee ID’s?II onlyI onlyBoth I and IINeither I nor II

Question

Suppose we wish to find the ID’s of the employees that are managed by people who are managed by the employee with ID 123. Here are two possible queries:I.SELECT ee.empIDFROM Emps ee, Emps ffWHERE ee.mgrID = ff.empID AND ff.mgrID = 123;II.SELECT empIDFROM Emps WHERE mgrID IN(SELECT empID FROM Emps WHERE mgrID = 123);Which, if any, of the two queries above will correctly (in SQL2) get the desired set of employee ID’s?II onlyI onlyBoth I and IINeither I nor II

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

Solution

Both I and II

Similar Questions

Consider the table EMPLOYEE(empId, name, department, salary) and the two queries Q1 ,Q2 below. Assuming that department D5 has more than one employee, and we want to find the employees who get higher salary than anyone in department D5, which one of the statements is TRUE for any arbitrary employee table?Q1 :  SELECT  e.empId FROM employee e WHERE NOT EXIST (SELECT * From employee s where s.department = “D5” AND  s.salary >=e.salary)Q2 : SELECT  e.empIdFROM employee eWHERE e.salary > Any (Select distinct salary From employee s Where s.department = “D5”)Q1 is the correct queryQ2 is the correct queryBoth Q1 and Q2 produce the same answer.Neither Q1 nor Q2 is the correct query

Question 2A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?1 pointSELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPT_ID_DEP = E.DEP_IDSELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_IDSELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_IDSELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTS

Consider the following SQL statement:SELECT employee_id FROM employeesUNIONSELECT employee_id FROM former_employees;What does this statement do?Returns the employee IDs of all current employees.Returns the employee IDs of all former employees.Returns the employee IDs of both current and former employees, eliminating duplicates.Returns the employee IDs of both current and former employees, including duplicates.Next

1.Question 1Which of the following queries will return the data for employees who belong to the department with the highest value of department ID.1 pointSELECT * FROM EMPLOYEES WHERE DEPT_ID_DEP = MAX ( SELECT DEPT_ID_DEP FROM DEPARTMENTS )SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT MAX(DEPT_ID_DEP) FROM DEPARTMENTS ) SELECT * FROM EMPLOYEES WHERE DEP_ID = MAX(DEP_ID) SELECT * FROM EMPLOYEES WHERE DEP_ID = ( SELECT DEPT_ID_DEP FROM DEPARTMENTS WHERE DEPT_ID_DEP IS MAX )2.Question 2A DEPARTMENTS table contains DEP_NAME, and DEPT_ID_DEP columns and an EMPLOYEES table contains columns called F_NAME and DEP_ID. We want to retrieve the Department Name for each Employee. Which of the following queries will correctly accomplish this?1 pointSELECT F_NAME, DEP_NAME FROM EMPLOYEES, DEPARTMENTS WHERE DEPT_ID_DEP = DEP_IDSELECT E.F_NAME, D.DEP_NAME FROM EMPLOYEES, DEPARTMENTSSELECT F_NAME, DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPT_ID_DEP = D.DEP_IDSELECT D.F_NAME, E.DEP_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPT_ID_DEP = E.DEP_ID3.Question 3You are writing a query that will give you the total cost to the Pet Rescue organization of rescuing animals. The cost of each rescue is stored in the Cost column. You want the result column to be called “Total_Cost”. Which of the following SQL queries is correct?1 pointSELECT SUM(Cost) FROM PetRescueSELECT SUM(Cost) AS Total_Cost FROM PetRescueSELECT SUM(Total_Cost) From PetRescueSELECT Total_Cost FROM PetRescue4.Question 4Which of the following is the correct syntax for calculating an employee’s age, in YYYY-MM-DD format, with respect to the current date, in MySQL? Assume the date of birth is available as a column ‘DOB’ in the table named ‘Employees’.1 pointSELECT (CURRENT_DATE – DOB) FROM EmployeesSELECT DATEDIFF(CURRENT_DATE, DOB) FROM EmployeesSELECT FROM_DAYS(DATEDIFF(CURRENT_DATE, DOB)) FROM EmployeesSELECT FROM_DAYS(DATE_SUB(CURRENT_DATE, DOB) FROM Employees5.Question 5You have a record of a set of medicines called ‘MEDS’. Their date of expiry is exactly 1 year after their date of manufacturing. The name of the medicines is available as ‘NAME’ and their date of manufacturing is available as a column ‘DOM’. Which of the commands will generate an output that contains name of the medicines and also displays their date of expiry as a column ‘DOE’? Assume use of MySQL.1 pointSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATEADD(DOM, INTERVAL 1 YEAR) FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEAR) AS DOE FROM MEDSSELECT NAME, DATE_ADD(DOM, INTERVAL 1 YEARS) AS DOE FROM MEDS

Which of the following is the correct query to find all the orders against the employee who works   for the customer whose id is 1234 ?The required tables are :Employee(eid, name, city) and orders (ord_no, purch_amt, ord_date, customer_id, eid)OPTIONS:-ASelect * from orders where eid (select DISTINCT  eid from orders where customer_id=1234) order by eid.BSelect * from orders where eid=(select DISTINCT eid from orders where customer_id=1234);CSelect * from orders where eid = (select  eid from orders) where customer_id=1234;DSelect * from salesman where eid =(select DISTINCT  eid from orders) where customer_id=1234;

1/2

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.