Q41. What is the IN operator?
Answer:IN
allows you to specify multiple values in a WHERE clause.
Example: SELECT * FROM Employees WHERE Department IN ('HR', 'Finance');
Q42. What is the EXISTS operator?
Answer:EXISTS
checks if a subquery returns any records.
Example: SELECT Name FROM Employees
WHERE EXISTS (SELECT 1 FROM Departments WHERE Employees.DepartmentID = Departments.DepartmentID);
Q43. What is a CASE statement in SQL?
Answer:CASE
is used for conditional logic inside SQL queries.
Example: SELECT Name,
CASE
WHEN Age < 18 THEN 'Minor'
ELSE 'Adult'
END AS Status
FROM Employees;
Q44. What is COALESCE function?
Answer:COALESCE
returns the first non-NULL value among its arguments.
Example: SELECT Name, COALESCE(Address, 'Address Not Available') FROM Customers;
Q45. What is the ISNULL() function?
Answer:ISNULL()
replaces NULL with a specified replacement value.
Example: SELECT ISNULL(Address, 'N/A') FROM Customers;
Q46. What is the DISTINCT keyword?
Answer:DISTINCT
is used to return only unique (different) values.
Example: SELECT DISTINCT Department FROM Employees;
Q47. What is the LIKE operator in SQL?
Answer:
(Already given earlier, here again with simple version)
SELECT * FROM Customers WHERE CustomerName LIKE 'A%';
Finds all customer names starting with ‘A’.
Q48. What is an Aggregate Function?
Answer:
Aggregate functions perform a calculation on a set of values and return a single value.
Function | Use |
---|---|
COUNT() | Counts number of rows |
SUM() | Calculates total sum |
AVG() | Calculates average |
MAX() | Finds maximum value |
MIN() | Finds minimum value |
Q49. What is a Scalar Function?
Answer:
Scalar functions operate on a single value and return a single value.
Example Function | Purpose |
---|---|
UPPER() | Converts to uppercase |
LOWER() | Converts to lowercase |
LEN() | Returns string length |
Q50. What is the difference between CHAR and VARCHAR?
Answer:
CHAR | VARCHAR |
---|---|
Fixed length | Variable length |
Always reserves space | Uses only required space |
Faster access | Saves memory |
Example:
CHAR(10): Reserves 10 bytes even if 5 characters entered.
VARCHAR(10): Uses only 5 bytes if 5 characters entered.
Top 50 Intermediate SQL Interview Questions You Must Practice [With Examples]
Top 50 Advanced SQL Questions asked in Top Companies (with Answers + Examples)
2 thoughts on “Top 50 Basic Level SQL Interview Questions – Beginners Guide”