Top1oo Entry Level SQL Interview Question
Top1oo Entry Level SQL Interview Question
INTERVIEW
QUESTIONS & ANSWERS
employee
2. What is a database?
Answer: A database is a structured collection of data.
Ini Akpabio
4. What is a record in a database table?
Ini Akpabio
7. How do you retrieve all the columns from a table named "employees"?
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"?
Ini Akpabio
10. What is the purpose of the DISTINCT keyword in a SELECT statement?
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?
Ini Akpabio
13. How do you add a new record to a table named "customers"?
Answer: INSERT INTO customers (column1, column2, ...) VALUES (value1, value2, ...);
15. How do you delete all records from a table named "orders"?
Ini Akpabio
16. What is an aggregate function in SQL?
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: The BETWEEN operator is used to filter the result set within a specific range.
Ini Akpabio
22. How do you retrieve distinct values from a column named "category" in a table named
"products"?
Answer: The LIKE operator is used to search for a specified pattern in a column.
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: ORDER BY is used to sort the result set based on one or more columns.
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: `INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2,
...);
Ini Akpabio
31. How do you retrieve the first n records from a table named "employees"?
Ini Akpabio
34. What is the purpose of the DESC keyword in a SQL query?
36. How do you retrieve the total number of records in a table named "orders"?
Ini Akpabio
37. What is the purpose of the SUM() function in SQL?
38. How do you rename a column named "old_column" to "new_column" in a table named
"my_table"?
Answer: A foreign key is a column or a set of columns that refers to the primary key of
another table.
Ini Akpabio
40. How do you retrieve the last n records from a table named "transactions"?
Ini Akpabio
43. How do you add a new column named "new_column" to a table named "my_table"?
Answer: NULLIF() returns NULL if two expressions are equal; otherwise, it returns
the first expression.
Ini Akpabio
46. How do you retrieve unique values from a column named "color" in a table named
"products"?
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"?
Ini Akpabio
49. Explain the basic syntax of the CREATE TABLE statement.
50. How do you retrieve the current date and time in a SQL query?
Answer: The LIKE operator is used for pattern matching within a specified column.
Ini Akpabio
52. How do you retrieve the top n records from a table named "products" based on a column
named "sales"?
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?
Ini Akpabio
58. How do you retrieve records where a column named "status" is either 'Open' or 'Pending'?
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'?
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: A composite key consists of two or more columns that together uniquely
identify a record.
Ini Akpabio
64. How do you retrieve the last record from a table named "transactions"?
66. How do you retrieve records where a column named "date" falls within a specific range?
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"?
Ini Akpabio
70. How do you retrieve the records with the highest salary from a table named "employees"?
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"?
Ini Akpabio
73. Explain the purpose of the CASCADE option in a foreign key constraint.
74. How do you retrieve the total number of records in a table named "customers" where the
city is 'New York'?
Answer: BETWEEN is used to filter the result set within a specific range.
Ini Akpabio
76. How do you retrieve the records with the lowest salary from a table named "employees"?
78. How do you retrieve the records where a column named "quantity" is not equal to 0?
Ini Akpabio
76. How do you retrieve the records with the lowest salary from a table named "employees"?
78. How do you retrieve the records where a column named "quantity" is not equal to 0?
Ini Akpabio
79. What is the purpose of the COALESCE() function in SQL?
80. How do you retrieve the total number of records in a table named "products" where the
price is greater than 50?
Answer: JOIN is used to combine rows from two or more tables based on a related
column.
Ini Akpabio
82. How do you retrieve records where a column named "name" contains the substring
'Tech'?
84. How do you retrieve records where a column named "date" is in the current year?
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"?
Ini Akpabio
88. How do you retrieve records where a column named "name" ends with the letter 's'?
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?
Ini Akpabio
91. What is the purpose of the AVG() function in SQL?
92. How do you retrieve records where a column named "name" is not null?
Ini Akpabio
94. How do you retrieve records where a column named "status" is 'Complete' or 'Cancelled'?
96. How do you retrieve records where a column named "date" is in the past month?
Ini Akpabio
97. Explain the concept of the UNIQUE constraint in SQL.
98. How do you retrieve the records with the highest salary from a table named "employees"
excluding duplicates?
Ini Akpabio
100. How do you retrieve records where a column named "quantity" is greater than or equal
to 10?
Ini Akpabio