Question
Option 4 : Amit, Chetan / Amit, Chetan
Detailed Solution
सही उत्तर Amit, Chetan / Amit, Chetan है।
Question:
Tables: departments(dept_id, name, location) has rows (10, 'HR', 'Delhi'), (20, 'IT', 'Mumbai'), (30, 'Accounts', 'Delhi'); employees(name, dept_id) has rows ('Amit', 10), ('Bina', 20), ('Chetan', 30), ('Divya', 20). What does this query return? / टेबल: departments(dept_id, name, location) में पंक्तियाँ (10, 'HR', 'Delhi'), (20, 'IT', 'Mumbai'), (30, 'Accounts', 'Delhi') हैं; employees(name, dept_id) में पंक्तियाँ ('Amit', 10), ('Bina', 20), ('Chetan', 30), ('Divya', 20) हैं। यह क्वेरी क्या लौटाती है?
SELECT name FROM employees WHERE dept_id IN (SELECT dept_id FROM departments WHERE location = 'Delhi') ORDER BY name;
Correct Answer: Amit, Chetan / Amit, Chetan
The inner query returns dept_ids 10 and 30 (the Delhi departments). The outer query keeps employees whose dept_id is 10 or 30: Amit (10) and Chetan (30); Bina and Divya (dept 20, Mumbai) are filtered out, and ORDER BY name gives Amit, Chetan. / आंतरिक क्वेरी dept_id 10 और 30 लौटाती है (दिल्ली के विभाग)। बाहरी क्वेरी उन्हीं कर्मचारियों को रखती है जिनका dept_id 10 या 30 है: Amit (10) और Chetan (30); Bina और Divya (विभाग 20, मुंबई) छँट जाते हैं, और ORDER BY name से Amit, Chetan मिलता है।