Database
Aptitude · Reasoning · English · CS — Corporate & Campus Interview Prep
26 Questions 10 Topics Take Test
Advertisement
Showing 11–20 of 26 questions
Q.11 Medium SQL Basics
Given a table 'employees' with salary column, which query finds employees earning more than average salary?
A SELECT * FROM employees WHERE salary > AVG(salary);
B SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
C SELECT * FROM employees HAVING salary > AVG(salary);
D SELECT AVG(salary) FROM employees WHERE salary > average;
Correct Answer:  B. SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
Explanation:

Aggregate functions cannot be used directly in WHERE clause. Must use subquery in parentheses to calculate average first.

Take Test
Q.12 Medium SQL Basics
What is the difference between CROSS JOIN and INNER JOIN?
A CROSS JOIN returns Cartesian product; INNER JOIN requires join condition
B Both are identical
C INNER JOIN is always faster
D CROSS JOIN filters NULL values
Correct Answer:  A. CROSS JOIN returns Cartesian product; INNER JOIN requires join condition
Explanation:

CROSS JOIN produces all combinations of rows (m×n rows if m and n are table sizes). INNER JOIN filters based on condition.

Take Test
Q.13 Medium SQL Basics
Which statement correctly uses aliases in SQL?
A SELECT column_name AS 'alias name' FROM table;
B SELECT column_name alias_name FROM table;
C SELECT column_name AS alias_name FROM table;
D SELECT column_name FROM table AS alias;
Correct Answer:  C. SELECT column_name AS alias_name FROM table;
Explanation:

Correct syntax uses AS keyword with alias without quotes (unless alias has spaces). Option A uses unnecessary quotes, B omits AS.

Take Test
Q.14 Medium SQL Basics
For a query with transactions table, which index type is most efficient for WHERE clauses checking transaction_date range?
A Hash Index
B B-Tree Index
C Full-Text Index
D Spatial Index
Correct Answer:  B. B-Tree Index
Explanation:

B-Tree indexes are optimal for range queries (BETWEEN, <, >). Hash indexes are for equality, Full-Text for text search, Spatial for geographic data.

Take Test
Q.15 Medium SQL Basics
What is the output of: SELECT COALESCE(NULL, NULL, 'SQL', 'Database');?
A NULL
B 'SQL'
C 'Database'
D Error
Correct Answer:  B. 'SQL'
Explanation:

COALESCE returns first non-NULL value. It skips two NULLs and returns 'SQL' as first non-NULL argument.

Take Test
Advertisement
Q.16 Medium SQL Basics
In a normalized database following 3NF, which anomaly is prevented?
A Only insertion anomaly
B Only deletion anomaly
C Update, insertion, and deletion anomalies
D Only update anomaly
Correct Answer:  C. Update, insertion, and deletion anomalies
Explanation:

3NF (Third Normal Form) eliminates update, insertion, and deletion anomalies by removing transitive dependencies.

Take Test
Q.17 Medium SQL Basics
Which of the following queries demonstrates a self-join correctly?
A SELECT * FROM employees e1, employees e2 WHERE e1.manager_id = e2.emp_id;
B SELECT * FROM employees JOIN employees ON emp_id = manager_id;
C SELECT * FROM employees UNION SELECT * FROM employees;
D SELECT * FROM employees WHERE emp_id = emp_id;
Correct Answer:  A. SELECT * FROM employees e1, employees e2 WHERE e1.manager_id = e2.emp_id;
Explanation:

Self-join requires table aliasing (e1, e2) to reference same table twice with join condition. Option B lacks aliases, C uses UNION, D is illogical.

Take Test
Q.18 Medium SQL Basics
In a bank database with accounts and transactions tables, to find accounts with transactions greater than 100,000, which clause must follow GROUP BY?
A WHERE
B HAVING
C ORDER BY
D LIMIT
Correct Answer:  B. HAVING
Explanation:

HAVING clause filters grouped results after aggregation. WHERE filters before grouping. Use HAVING with aggregate functions.

Take Test
Q.19 Medium SQL Basics
What will be the result of: SELECT 10/3 in SQL?
A 3.33
B 3
C 3.0
D Null
Correct Answer:  B. 3
Explanation:

Integer division in SQL returns integer result (3). Use CAST or decimal numbers for decimal division result.

Take Test
Q.20 Medium SQL Basics
A company table has 500K employee records. To find employees with salary > 50,000 efficiently, which strategy is optimal?
A Create clustered index on salary column
B Use SELECT * without WHERE clause then filter in application
C Create non-clustered index on salary for faster filtering
D Use UNION ALL with multiple queries
Correct Answer:  C. Create non-clustered index on salary for faster filtering
Explanation:

Non-clustered index on salary column enables fast filtering. Clustered index affects primary key ordering. Filtering in application is inefficient.

Take Test
IGET
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! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips