TOP 100 ENTRY LEVEL SQL
INTERVIEW
QUESTIONS & ANSWERS
employee
emp_id first_name emp_sal emp_dept
001 Michael $10,000 IS Ini Akpabio
002 Susan $12,000 HR
1. What does SQL stand for?
Answer: SQL stands for Structured Query Language.
2. What is a database?
Answer: A database is a structured collection of data.
3. What is a table in a database?
Answer: A table is a collection of related data entries organized in rows and columns.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
4. What is a record in a database table?
Answer: A record is a complete set of fields representing a single entry in a
table.
5. What is a column in a database table?
Answer: A column is a set of data values of a particular type within a table.
6. Explain the basic syntax of the SELECT statement.
Answer: SELECT column1, column2 FROM table_name WHERE condition;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
7. How do you retrieve all the columns from a table named "employees"?
Answer: SELECT * FROM employees;
8. What is a WHERE clause used for in a SQL query?
Answer: The WHERE clause is used to filter records based on a specified condition.
9. How do you sort the result set of a query in ascending order by a column named "salary"?
Answer: SELECT * FROM employees ORDER BY salary ASC;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
10. What is the purpose of the DISTINCT keyword in a SELECT statement?
Answer: The DISTINCT keyword is used to retrieve unique values in a column.
11. What does the LIMIT clause do in a SQL query?
Answer: The LIMIT clause is used to limit the number of rows returned in a result set.
12. What is the difference between CHAR and VARCHAR data types?
Answer: CHAR is a fixedlength string, while VARCHAR is a variablelength string.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
13. How do you add a new record to a table named "customers"?
Answer: INSERT INTO customers (column1, column2, ...) VALUES (value1, value2, ...);
14. What is the purpose of the UPDATE statement?
Answer: The UPDATE statement is used to modify existing records in a table.
15. How do you delete all records from a table named "orders"?
Answer: DELETE FROM orders;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
16. What is an aggregate function in SQL?
Answer: An aggregate function performs a calculation on a set of values and returns a
single value.
17. What is the result of the COUNT(*) function in SQL?
Answer: COUNT(*) returns the number of rows in a table.
18. Explain the concept of NULL in a database.
Answer: NULL represents the absence of a value in a database.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
19. What is a primary key, and why is it important?
Answer: A primary key is a unique identifier for a record in a table, ensuring data
integrity.
20. How do you retrieve data from two or more tables using a SQL JOIN?
Answer: SELECT * FROM table1 INNER JOIN table2 ON table1.column =
table2.column;
21. What is the purpose of the BETWEEN operator in a SQL query?
Answer: The BETWEEN operator is used to filter the result set within a specific range.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
22. How do you retrieve distinct values from a column named "category" in a table named
"products"?
Answer: SELECT DISTINCT category FROM products;
23. What is the purpose of the LIKE operator in a SQL query?
Answer: The LIKE operator is used to search for a specified pattern in a column.
24. What is the default sorting order in a SQL query?
Answer: The default sorting order is ascending (ASC).
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
25. Explain the purpose of the GROUP BY clause in SQL.
Answer: GROUP BY is used to arrange identical data into groups based on the values
of one or more columns.
26. How do you calculate the average value of a column named "price" in a table named
"products"?
Answer: SELECT AVG(price) FROM products;
27. What is the purpose of the ORDER BY clause in a SQL query?
Answer: ORDER BY is used to sort the result set based on one or more columns.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
28. How do you update the value of a column named "quantity" in a table named "inventory"
where the product is "Widget"?
Answer: UPDATE inventory SET quantity = new_value WHERE product = 'Widget';
29. What is the purpose of the DISTINCT keyword in a SELECT statement?
Answer: DISTINCT is used to retrieve unique values in a column.
30. Explain the basic syntax of the INSERT INTO statement.
Answer: `INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2,
...);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
31. How do you retrieve the first n records from a table named "employees"?
Answer: SELECT * FROM employees LIMIT n;
32. What is the purpose of the AVG() function in SQL?
Answer: AVG() calculates the average value of a numeric column.
33. How do you remove a table named "customers" from a database?
Answer: DROP TABLE customers;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
34. What is the purpose of the DESC keyword in a SQL query?
Answer: DESC is used to sort the result set in descending order.
35. Explain the basic syntax of the DELETE statement.
Answer: DELETE FROM table_name WHERE condition;
36. How do you retrieve the total number of records in a table named "orders"?
Answer: SELECT COUNT(*) FROM orders;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
37. What is the purpose of the SUM() function in SQL?
Answer: SUM() calculates the sum of values in a numeric column.
38. How do you rename a column named "old_column" to "new_column" in a table named
"my_table"?
Answer: ALTER TABLE my_table RENAME COLUMN old_column TO new_column;
39. Explain the concept of a foreign key in a database.
Answer: A foreign key is a column or a set of columns that refers to the primary key of
another table.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
40. How do you retrieve the last n records from a table named "transactions"?
Answer: SELECT * FROM transactions ORDER BY id DESC LIMIT n;
41. What is the purpose of the MIN() function in SQL?
Answer: MIN() returns the minimum value in a numeric column.
42. Explain the basic syntax of the UPDATE statement.
Answer: `UPDATE table_name SET column1 = value1, column2 = value2 WHERE
condition;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
43. How do you add a new column named "new_column" to a table named "my_table"?
Answer: ALTER TABLE my_table ADD COLUMN new_column datatype;
44. What is the purpose of the COUNT() function in SQL?
Answer: COUNT() returns the number of rows in a result set.
45. Explain the concept of the NULLIF() function in SQL.
Answer: NULLIF() returns NULL if two expressions are equal; otherwise, it returns
the first expression.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
46. How do you retrieve unique values from a column named "color" in a table named
"products"?
Answer: SELECT DISTINCT color FROM products;
47. What is the purpose of the TOP keyword in a SQL query?
Answer: TOP is used to limit the number of rows returned in a result set.
48. How do you retrieve the second highest value from a column named "score" in a table
named "students"?
Answer: SELECT MAX(score) FROM students WHERE score < (SELECT
MAX(score) FROM students);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
49. Explain the basic syntax of the CREATE TABLE statement.
Answer: CREATE TABLE table_name (column1 datatype, column2 datatype, …);
50. How do you retrieve the current date and time in a SQL query?
Answer: SELECT CURRENT_TIMESTAMP;
51. What is the purpose of the LIKE operator in a SQL query?
Answer: The LIKE operator is used for pattern matching within a specified column.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
52. How do you retrieve the top n records from a table named "products" based on a column
named "sales"?
Answer: SELECT * FROM products ORDER BY sales DESC LIMIT n;
53. Explain the purpose of the TRUNCATE TABLE statement.
Answer: TRUNCATE TABLE is used to delete all rows from a table but retains the
structure for future use.
54. How do you add a constraint to a column named "age" to ensure it only contains positive
values?
Answer: ALTER TABLE table_name ADD CONSTRAINT check_age CHECK (age >
0);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
55. What is the purpose of the IN operator in a SQL query?
Answer: The IN operator is used to specify multiple values in a WHERE clause.
56. How do you retrieve the current user in a SQL query?
Answer: SELECT CURRENT_USER;
57. Explain the basic syntax of the CREATE DATABASE statement.
Answer: CREATE DATABASE database_name;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
58. How do you retrieve records where a column named "status" is either 'Open' or 'Pending'?
Answer: SELECT * FROM table_name WHERE status IN ('Open', 'Pending');
59. What is the purpose of the UNION operator in a SQL query?
Answer: UNION is used to combine the results of two or more SELECT statements.
60. How do you retrieve records where a column named "name" starts with the letter 'A'?
Answer: SELECT * FROM table_name WHERE name LIKE 'A%';
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
61. What is the purpose of the IS NULL operator in a SQL query?
Answer: IS NULL is used to filter results where a column has a NULL value.
62. How do you retrieve the average salary from a table named "employees"?
Answer: SELECT AVG(salary) FROM employees;
63. Explain the concept of a composite key in a database.
Answer: A composite key consists of two or more columns that together uniquely
identify a record.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
64. How do you retrieve the last record from a table named "transactions"?
Answer: SELECT * FROM transactions ORDER BY id DESC LIMIT 1;
65. What is the purpose of the RAND() function in a SQL query?
Answer: RAND() generates a random number between 0 and 1.
66. How do you retrieve records where a column named "date" falls within a specific range?
Answer: SELECT * FROM table_name WHERE date BETWEEN 'start_date' AND
'end_date';
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
67. What is the purpose of the ALL operator in a SQL query?
Answer: ALL is used to compare a value to all values in another result set or a list.
68. How do you retrieve the total number of distinct values in a column named "category"
from a table named "products"?
Answer: SELECT COUNT(DISTINCT category) FROM products;
69. Explain the basic syntax of the CREATE INDEX statement.
Answer: CREATE INDEX index_name ON table_name (column1, column2, ...);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
70. How do you retrieve the records with the highest salary from a table named "employees"?
Answer: SELECT * FROM employees WHERE salary = (SELECT MAX(salary)
FROM employees);
71. What is the purpose of the ANY operator in a SQL query?
Answer: ANY is used to compare a value to any value in another result set or a list.
72. How do you retrieve the current month from a date column named "order_date"?
Answer: SELECT MONTH(order_date) FROM table_name;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
73. Explain the purpose of the CASCADE option in a foreign key constraint.
Answer: CASCADE automatically deletes or updates the corresponding records in the
child table when a record in the parent table is deleted or updated.
74. How do you retrieve the total number of records in a table named "customers" where the
city is 'New York'?
Answer: SELECT COUNT(*) FROM customers WHERE city = 'New York';
75. What is the purpose of the BETWEEN operator in a SQL query?
Answer: BETWEEN is used to filter the result set within a specific range.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
76. How do you retrieve the records with the lowest salary from a table named "employees"?
Answer: SELECT * FROM employees WHERE salary = (SELECT MIN(salary) FROM
employees);
77. Explain the basic syntax of the CREATE VIEW statement.
Answer: CREATE VIEW view_name AS SELECT column1, column2, ... FROM
table_name WHERE condition;
78. How do you retrieve the records where a column named "quantity" is not equal to 0?
Answer: SELECT * FROM table_name WHERE quantity <> 0;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
76. How do you retrieve the records with the lowest salary from a table named "employees"?
Answer: SELECT * FROM employees WHERE salary = (SELECT MIN(salary) FROM
employees);
77. Explain the basic syntax of the CREATE VIEW statement.
Answer: CREATE VIEW view_name AS SELECT column1, column2, ... FROM
table_name WHERE condition;
78. How do you retrieve the records where a column named "quantity" is not equal to 0?
Answer: SELECT * FROM table_name WHERE quantity <> 0;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
79. What is the purpose of the COALESCE() function in SQL?
Answer: COALESCE() returns the first nonnull expression in a list.
80. How do you retrieve the total number of records in a table named "products" where the
price is greater than 50?
Answer: SELECT COUNT(*) FROM products WHERE price > 50;
81. Explain the purpose of the JOIN clause in a SQL query.
Answer: JOIN is used to combine rows from two or more tables based on a related
column.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
82. How do you retrieve records where a column named "name" contains the substring
'Tech'?
Answer: SELECT * FROM table_name WHERE name LIKE '%Tech%';
83. What is the purpose of the CASE statement in SQL?
Answer: CASE is used to perform conditional logic in a SQL query.
84. How do you retrieve records where a column named "date" is in the current year?
Answer: SELECT * FROM table_name WHERE YEAR(date) =
YEAR(CURRENT_DATE);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
85. Explain the concept of the PRIMARY KEY constraint in a database.
Answer: PRIMARY KEY uniquely identifies each record in a table and ensures data
integrity.
86. How do you retrieve the distinct values from two columns named "category" and
"sub_category" in a table named "products"?
Answer: SELECT DISTINCT category, sub_category FROM products;
87. What is the purpose of the DISTINCT keyword in a SQL query?
Answer: DISTINCT is used to retrieve unique values in a column.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
88. How do you retrieve records where a column named "name" ends with the letter 's'?
Answer: SELECT * FROM table_name WHERE name LIKE '%s';
89. Explain the concept of the CHECK constraint in SQL.
Answer: CHECK is used to limit the range of values that can be placed in a column.
90. How do you retrieve records where a column named "price" is in the range of 20 to 50?
Answer: SELECT * FROM table_name WHERE price BETWEEN 20 AND 50;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
91. What is the purpose of the AVG() function in SQL?
Answer: AVG() calculates the average value of a numeric column.
92. How do you retrieve records where a column named "name" is not null?
Answer: SELECT * FROM table_name WHERE name IS NOT NULL;
93. Explain the purpose of the MAX() function in SQL.
Answer: MAX() returns the maximum value in a numeric column.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
94. How do you retrieve records where a column named "status" is 'Complete' or 'Cancelled'?
Answer: SELECT * FROM table_name WHERE status IN ('Complete', 'Cancelled');
95. What is the purpose of the MIN() function in SQL?
Answer: MIN() returns the minimum value in a numeric column.
96. How do you retrieve records where a column named "date" is in the past month?
Answer: SELECT * FROM table_name WHERE date >= DATE_SUB(CURDATE(),
INTERVAL 1 MONTH);
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
97. Explain the concept of the UNIQUE constraint in SQL.
Answer: UNIQUE ensures that all values in a column are unique.
98. How do you retrieve the records with the highest salary from a table named "employees"
excluding duplicates?
Answer: SELECT DISTINCT * FROM employees WHERE salary = (SELECT
MAX(salary) FROM employees);
99. What is the purpose of the SUM() function in SQL?
Answer: SUM() calculates the sum of values in a numeric column.
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio
100. How do you retrieve records where a column named "quantity" is greater than or equal
to 10?
Answer: SELECT * FROM table_name WHERE quantity >= 10;
TOP 100 ENTRY LEVEL SQL INTERVIEW QUESTIONS & ANSWERS
Ini Akpabio