Home Subjects Database

Database

SQL queries, DBMS, normalization, transactions

26 Q 1 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–26 of 26
Topics in Database
All SQL Basics 57
Q.21 Medium SQL Basics
Which SQL function is used to count non-NULL values in a column?
A COUNT(column_name)
B SUM(column_name)
C MAX(column_name)
D AVG(column_name)
Correct Answer:  A. COUNT(column_name)
EXPLANATION

COUNT(column_name) counts the number of non-NULL values in the specified column. COUNT(*) counts all rows.

Test
Q.22 Medium SQL Basics
What will be the result of this query: SELECT * FROM employees WHERE salary > 50000 AND department = 'IT';
A All employees with salary greater than 50000 or in IT department
B Only IT employees with salary greater than 50000
C All IT employees regardless of salary
D Employees with salary greater than 50000 in any department
Correct Answer:  B. Only IT employees with salary greater than 50000
EXPLANATION

The AND operator requires both conditions to be true, so only employees in IT department with salary > 50000 are returned.

Test
Q.23 Medium SQL Basics
What is the difference between WHERE and HAVING clauses?
A WHERE filters rows before grouping; HAVING filters groups after grouping
B HAVING filters rows; WHERE filters groups
C They are identical and interchangeable
D WHERE is used with JOIN; HAVING is used with SELECT
Correct Answer:  A. WHERE filters rows before grouping; HAVING filters groups after grouping
EXPLANATION

WHERE filters individual rows before GROUP BY is applied, while HAVING filters the grouped results after GROUP BY is applied.

Test
Q.24 Medium SQL Basics
Which SQL clause is used to sort the result set in ascending or descending order?
A WHERE
B ORDER BY
C GROUP BY
D HAVING
Correct Answer:  B. ORDER BY
EXPLANATION

The ORDER BY clause sorts the result set in ascending (ASC) or descending (DESC) order. Default is ascending.

Test
Q.25 Medium SQL Basics
Which type of JOIN returns only matching rows from both tables?
A LEFT JOIN
B RIGHT JOIN
C INNER JOIN
D FULL OUTER JOIN
Correct Answer:  C. INNER JOIN
EXPLANATION

INNER JOIN returns only the rows that have matching values in both tables being joined.

Test
Q.26 Medium SQL Basics
What is the purpose of the JOIN clause in SQL?
A To combine rows from two or more tables based on related columns
B To delete records from a table
C To update multiple rows at once
D To create a backup of a table
Correct Answer:  A. To combine rows from two or more tables based on related columns
EXPLANATION

JOIN combines rows from two or more tables based on a relationship between the columns (usually foreign key relationship).

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