In a manufacturing database, to find products with sales in ALL regions, which approach is correct?
ASELECT product_id FROM sales GROUP BY product_id HAVING COUNT(DISTINCT region) = (SELECT COUNT(*) FROM regions)
BSELECT product_id FROM sales WHERE region IN (SELECT DISTINCT region FROM sales)
CSELECT DISTINCT product_id FROM sales s1 WHERE region = 'North' AND EXISTS (SELECT 1 FROM sales WHERE product_id = s1.product_id)
DSELECT product_id FROM sales WHERE region = 'North' OR region = 'South'
Correct Answer:
A. SELECT product_id FROM sales GROUP BY product_id HAVING COUNT(DISTINCT region) = (SELECT COUNT(*) FROM regions)
EXPLANATION
Counts distinct regions per product and compares to total regions. Option B doesn't ensure ALL regions. Option C only checks one region. Option D is incomplete.
For optimizing a complex query joining 5 tables with WHERE conditions, what is the recommended approach?
AAlways use INNER JOINs first, then add WHERE conditions
BUse indexes on join columns and filter columns, check execution plan, simplify subqueries
CRewrite as multiple simple queries and combine in application
DUse VIEW instead of direct query
Correct Answer:
B. Use indexes on join columns and filter columns, check execution plan, simplify subqueries
EXPLANATION
Proper indexing on join and filter columns is crucial. Analyzing execution plan identifies bottlenecks. Application-level combining is inefficient. VIEWs don't inherently optimize.
iGET offers 12+ free Database MCQ questions covering all important topics. Each question is prepared by subject experts and comes with detailed explanations to help you understand concepts deeply, not just memorize answers.
Why prepare with iGET?
100% free access, timed mock tests, instant results with detailed analysis, topic-wise progress tracking, and bookmark feature for revision. Trusted by thousands of aspirants preparing for UPSC, SSC, Bank, Railway, NEET, JEE and other competitive exams across India.
How to use this page effectively
Start by selecting a difficulty level (Easy / Medium / Hard) or pick a specific topic from the topics strip. Attempt questions, check your answer instantly, read the explanation carefully, and bookmark tricky ones for later revision. For full exam-style practice, take a Mock Test from the right sidebar.
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.
Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯