Management & CommerceHardBusiness analyst · SQL test
Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran, Ops, 50, NULL), (5, Dev, Ops, 70, 4), (6, Neha, Ops, NULL, 4). Which employees does this return? SELECT name FROM emp e WHERE salary > (SELECT AVG(salary) FROM emp e2 WHERE e2.dept = e.dept)
- A. Asha and Dev
- B. Asha, Meena and Dev
- C. Asha only
- D. Asha, Meena, Dev and Neha
Correct answer: A. Asha and Dev
The correlated subquery computes each department's average: Sales 75, Ops 60 (NULL ignored). Asha (90 > 75) and Dev (70 > 60) qualify; Meena's 75 is not greater than 75; Neha's NULL comparison is unknown.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran…
- Daily demand is a steady 50 units, the order quantity is 200 units, and the supplier's lead time is 10 days. At what on-hand stock level…
- Lead-time demand is normal with a standard deviation of 40 units, and the firm holds 60 units of safety stock. What cycle-service level…
- Product X (lead time 1 week) needs 2 units of Y; Y (lead time 2 weeks) needs 3 units of Z; Z has a lead time of 1 week. 100 units of X are…
- Four jobs wait at one machine (processing hours; weight = importance): A (4; 1), B (2; 3), C (6; 2), D (3; 3). Using the weighted shortest…
- Seven jobs taking 8, 7, 6, 5, 4, 3 and 2 hours are to be run on three identical parallel machines. Using the longest-processing-time (LPT)…