Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 4 : Amit, Chetan / Amit, Chetan

Advertisement

Detailed Solution

सही उत्तर Amit, Chetan / Amit, Chetan है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

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;

1.
Amit, Bina / Amit, Bina
2.
Bina, Divya / Bina, Divya
3.
Amit, Bina, Chetan / Amit, Bina, Chetan
4.
Amit, Chetan / Amit, Chetan

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 मिलता है।

Downloaded from PrepSnap (prepsnap.in)