Database
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
Showing 11–12 of 12 questions
Q.11
Hard
SQL Basics
For optimizing a complex query joining 5 tables with WHERE conditions, what is the recommended approach?
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.
Q.12
Hard
SQL Basics
In a manufacturing database, to find products with sales in ALL regions, which approach is correct?
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.