Last 10 Years SQL Interview Questions
Last 10 Years SQL Interview Questions
INTERVIEW QUESTIONS
Introducing the ultimate guide to help you nail your SQL interviews! We've got questions and
answers all prepared with the help of industry experts. Whether you're aiming for a job in SQL
development, Data analysis, Data science, Data engineering, or HL7 development, we've got
you covered!
Our guide is designed to boost your confidence and skills. It's packed with real-world scenarios,
best practices, and insider tips to help you stand out in interviews. Whether you're new to SQL
or a seasoned pro, this guide will help you ace those tough interview questions.
Saurabh Verma
(SQL Developer)
1. What are structure and Unstructured data?
2. What is the difference between TRUNCATE, DELETE and DROP?
3. Which is faster Truncate or Delete? Give the reason.
4. What is the difference between CHAR and VARCHAR?
5. What is the difference between VARCHAR and NVARCHAR?
6. How many types of SQL Language? OR What are the subsets of SQL?
7. Differences Between @@IDENTITY Vs SCOPE_IDENTITY () Vs IDENT_CURRENT in SQL?
8. What are the different types of database management systems?
9. What is Denormalization in a Database?
10. What is Normalization in a Database?
11. What are Constraints?
12. How many types of constraints are available?
13. What is Not Null Constraint?
14. What is Check Constraint?
15. What is the Default Constraint?
16. What is a Unique Key Constraint?
17. What is Primary Key Constraint?
18. What is a Foreign Key Constraint?
19. What is Composite Primary Key?
20. What is the difference between Primary key and Unique Key Constraint?
21. What are Temporary Tables in SQL?
22. What are the use cases of Temporary Tables?
23. Which Database Temporary Tables Store?
24. What are Different Types of Temporary Tables available in SQL?
25. Explain Local Temp Table?
26. Explain Global Temp Table?
27. What are Variables In SQL?
28. What is Table Variable In SQL?
29. What is the Difference Between Temporary Table and Table Variable?
30. Which is faster: Temporary Table or Table Variable?
31. Write a query to find the list of all tables which are created by the users.
32. Write a query to find the list of all objects which are available in the Database.
33. Write a query to find the list of all Stored Procedures Which are available in the Database.
34. Write a query to list all Object names and Types.
35. What is the difference between ISNULL and Null Function?
36. Explain one real time scenario of ISNULL and Null Function?
37. What is SQL?
38. What is the Difference Between SQL, PL\SQL, T-SQL, and MYSQL?
39. What is RDBMS?
40. What is SQL Server Management studio
41. What is the difference between Server and Database?
42. What is the difference between System Database and a user-defined database?
43. How many types of systems define databases in MS SQL Server?
44. Describe all system databases.
45. What are tables and fields in the database?
46. How many types of SQL Language? OR What are the subsets of SQL?
47. What is the purpose of DDL Language?
48. What is the purpose of DML Language?
49. What is Data Query Language (DQL)?
50. What is Data Control Language (DCL)?
51. What is Transaction Control Language (TCL)?
52. What is the purpose of DDL Language?
53. What is the purpose of DML Language?
54. What is Data Query Language (DQL)?
55. What is Data Control Language (DCL)?
56. What is Transaction Control Language (TCL)?
57. What is the difference between TRUNCATE, DELETE and DROP?
58. What does N mean in SQL?
59. What is the syntax used to comment on single lines and Multiple Line?
60. What are the disadvantages of not performing database Normalization?
61. What are Aggregate Functions?
62. What is Having Clause in SQL?
63. What is Difference between Having and Where Clause?
64. What is the difference between GETDATE() and GETUTCDATE()? Ans:
65. Explain the DATEADD() function?
66. Explain the DATEDIFF() function?
67. Explain the DATENAME() function?
68. What is the EOMONTH() function?
69. What is @@DATEFIRST?
70. What is ISDATE()?
71. What is a subquery?
72. What is the Nesting subquery?
73. What is the Co-related subquery?
74. What is a Derived table?
75. What are the SET operators in SQL? Explain in detail.
76. What is a UNION operator in SQL?
77. What is a UNION ALL operator in SQL?
78. What is an INTERSECT operator in SQL?
79. What is an EXCEPT operator in SQL?
80. What is the CTE?
81. What is Index in SQL?
82. How many types of Index in SQL?
83. What is Clustered Index?
84. What is a Non-Clustered Index?
85. What is PATINDEX?
86. What is LEN?
87. What is SUBSTRING?
88. What is LOWER?
89. What is UPPER?
90. What is Space?
91. What is Concat?
92. What is the CAST function in SQL?
93. What is the Convert in SQL?
94. Write a query to convert the datetime format in SQL?
95. Explain the Ranking functions on SQL?
96. What are the different types of Ranking Function?
97. What is the RANK() function?
98. What is the ROW_NUMBER() function?
99. What is the DENSE_RANK() function?
100.What is the NTILE() function?
101. How we can find the Name starting with a Vowel Letter.
102. How we can find the Name starting with a consonant Letter.
103. How can I find the Name ending with a Vowel Letter?
104. What is the Difference between Scan and Seek Operation?
105. What is the difference between Table Scan, Index Scan, And Index Seek?
106. What is Estimated vs. Actual Query Execution Plans?
107. Can you please provide a list of the properties Execution Plans?
108. What is a heap table?
109. What is the Covering index?
110. What are Views in SQL?
111. What is the DML Query In View?
112. List the Conditional Control Statements in SQL?
113. What are the Case Statements?
114. What are the IF...ELSE Statements?
115. Explain the while loop in SQL?
116. Can we use For Loop in SQL?
117. WHAT IS CURSOR?
118. List the Types of Cursors in SQL.
119. What is the CURSOR LIFE CYCLE?
120. WHY USE CURSORS?
121. What is @@FETCH_STATUS?
122. What is Trigger?
123. What are the main characteristics of trigger?
124. How many classes of triggers are in SQL Server?
125. How many types of DML Triggers?
126. What is The Importance of SQL Server Triggers?
127. List out the SQL Server Performance Tuning Tips which need to follow to increase the
performance of code.
128. What are ACID Properties?
129. What is Dirty Read?
130. What is Non Repeatable read?
131. What is Phantom Read?
132. What is Deadlock?
133. How do I know if I have a deadlock?
134. How SQL Server handles deadlocks?
135. How does SQL Server choose the victim?
136. How Do I Know Which Rows Were Updated, Inserted, or Deleted using a SQL Server DML
Trigger?
137. What is the SQL Server Trigger Usage Scenarios?
138. What is MAGIC TABLE in triggers?
139. How can Enabled or Disabled Trigger in SQL?
140. How to minimize deadlocks ?
141. What is the difference between Count(*) and Count(ColumnName)?
142. Write the syntax to create the ‘Training’ Database.
143. Create an employee table and insert the below data.
144. Add additional column Mobile Number on Employee table and add data on the same column.
145. How to Remove the address column from the employee table.
146. Write a query to Update First name = Ragu and LastName = Shayam for emp ID=2.
147. Write a query to Remove empid = 4 from the table.
148. Write a query to update DimEmployee to store 500 length characters for the column Title.
149. Create a duplicate table of DimCustomer With data.
150. Create a duplicate table of DimCustomer without any data.
151. Create an employee table and make an EMPID column as an identity column and insert some
values.
152. Write a Query to Truncate the Employee table.
153. Write a query to drop the Employee table.
154. Write a query to update the DimCustomer table to set Yearly Income = 60000 for the Customer
Key = 11002 and roll back the update.
155. Create a new table from the existing table DimCustomer with Name DimCustomerBachelors
without using create keyword.
156. Write a SQL query to create a Courses table with the following column and insert some data and
create constraints.
157. Create a Student table with the following columns and insert some data and create constraints.
158. Create a Feedetails table with the following columns and insert some data and create constraints.
159. DROP check Constraint which is created on RollNumber in the student table
160. Can we drop or delete data from the Parents table before deleting from child?
161. Write a query to list all Object names and Types.
162. Find the customer details which have English education as Bachelors and English Occupation is
Professional.(Table: DimCustomer).
163. Find the list of employees whose title is Marketing Assistant or department is Tool
Design.(Table:DimEmployee)
164. Write a query to order FactInternetSales in Descending order based on Order
date.(Table:FactInternetSales)
165. What is the default order in order by clauses? Ascending or Descending
166. What is the difference between ISNULL and Null Function?
167. Explain one real time scenario of ISNULL and Null Function?
168. Find the list of the customer details that don't have a middle name.(Table: DimCustomer).
169. Find the customer details from 11100 to 11350.(Table: DimCustomer).
170. Find the list of the employee which firstName starting with ‘P’.(Table:DimEmployee).
171. Find the list of the employee which firstName starting with ‘S’ and LastName ending with
‘D’.(Table:DimEmployee).
172. Find the customer details which address contain ‘Park Glenn’. (Table:DimCustomer).
173. Find the maximum, Minimum and average tax amount for the internet
sales.(Table:FactInternetSales).
174. Find the Maximum and Minimum UnitPrice on each order date.(Table: FactInternetSales).
175. Find the Average Yearly income of the English Education High School(Table: DimCustomer)
176. How Many total issues were raised in the Holidays.(Table: FactCallCenter).
177. How many total calls in the AM shift (Table: FactCallCenter).
178. Find the Ship date of Order number SO43700(Table: FactInternetSales)
179. Find the Buyer information which is Management in occupation or ‘Partial Co’ in education.(Table:
ProspectiveBuyer)
180. Find the total number of employees working in the ‘Engineering’ department.(Table:Dimemployee)
181. Find the list of employees who are still associated with the company.(Table:Dimemployee)
182. Find the total count of Married and Single customers.
183. write a Query to display today's date and end of month date?
184. Write a Query to display today’s day and end of month day.
185. Write a query to display the last working date of this month?
186. Write a query to generate the report and in the report need to display an additional column as
ReportGeneratedDate.
187. Employeekey = 10 resigned today and as per the company policy the notice period is 90 days.
Write a query to find the last working days.
188. Write a query to display BirthDay,BirthMonth and BirthYear from the BirthDate column using
DimEmployee table.
189. Find the Employee information which Birth Year is 1974
190. Find the Employee information who was born in december.
191. Find the Employee information who joined in 2007 in the organization.
192. Write a query to find the age of all employees.
193. Find the Employee information who have greater or equal to 10 years of experience in the
organization.
194. Find the list of employees who joined on Monday.
195. Write a query to display joining days of all employees.
196. Write a query to find the BirthDay, BirthMonth and BirthYear of the employee by using
DimEmployeeTable.
197. Find the details of an employee who has more than five years tenure in the organization.
198. Find the details of the employee who is more than 30 years old in age.
199. Find the details of Customer who made the first purchase. Use the DimCustomer table.
200. Write the query to split the values from the column FrenchEducation Column from the
DimCustomer before values of ‘+’ symbol if available.
201. Add a new column FullName in the DimCustomer table and update the fullname for the Male
customer only.
202. Write the query to find the monthly income of the customer.
203. Write the query to find the age when the employee joins the organization.
204. Write the query to find the first 10 letters from the address and also find the total length of the
address from the DimCustomer table.
205. Find the maximum and minimum Yearly income of the Management Englishoccupation.
206. Find the Average Yearly income of the Gestión Spanishoccupation.
207. Find the total number of Bachelors EnglishEducation customers.
208. Find the 07th Highest Yearly income of the customer.
209. Find the 06th Highest Yearly income of the customer of Bachelors EnglishEducation.
210. Find the list of customers that don't have a middle name.
211. Find the average UnitPrice of each SalesOrder and sort the data in descending order based on
SalesOrderNumber.(FactInternetSales)
212. Find the list of Product which is order more than 50 times.(FactInternetSales)
213. Find the list of Customers who purchase more than one product. (FactInternetSales).
214. Find the list of product information which paid the 10th highest tax amount.(FactInternetSales).
215. Find the list of products which have shiping day on Monday.(FactInternetSales)
216. Find the list of products which sales amount greater than average sales amount.
217. What are CURSOR LIMITATIONS?
218. Create any table and apply CLUSTERED index.
219. Create any table and apply a Non cluster index.
220. Write a Query to display 'M' as 'Married' and 'S' as 'UnMarried' from the MaritalStatus using the
DimEmployee table.
221. Write a query to Print A to Z in SQL using a while loop.
222. Write a query to update Suffix column three letters if Gender is Male and update four letters if
Gender is Female.(Use DimCustomer table )
223. Write a query to print the EmployeeKey, FirstName and LastName using Cursor.
224. Which is better performance wise Cursor or While loop?
225. What are Stored Procedures?
226. Why use stored procedures and advantages of stored procedures?
227. How many types Of Stored Procedures?
228. What is Parameter in Stored Procedures?
229. What are the purposes and advantages of stored procedures?
230. Determine when to use stored procedures to complete SQL Server tasks?
231. Explain About The Process Which Takes Place To Execute A Stored Routine?
232. Where The Procedures Are Stored In the Database?
233. Does Storing Of Data In Stored Procedures Increase The Access Time? Explain?
234. What Are The Uses Of Stored Procedure?
235. Given a table SELLERS with 3 column SELLER_ID, COUNTRY, and JOINING_DATE, write a
query to identify a number of sellers per country and order it in descending order of no. of sellers.
236. For the table in question 1 write a query to extract all sellers who joined on a Monday.
237. Given a table EMPLOYEE with two columns EMP_ID and SALARY, how can we extract alternate
rows from a table?
238. find distinct values without using distinct keywords?
239. Given a table EMPLOYEE with two columns EMP_ID and SALARY, extract the employees with
the 3rd highest salary.
240. What is wrong with this SQL query? Correct it so it executes properly. SELECT SELLER_ID,
YEAR(JOINING_DATE) BILLINGYEAR FROM SELLERS WHERE JOINING_DATE >= 2010;
241. Assume a schema of EMP ( ID, NAME, DEPTID ) , DEPT ( ID, NAME).
242. If there are 10 records in the EMP table and 5 records in the DEPT table, how many rows will be
displayed in the result of the following SQL query:
243. SELECT * FROM EMP, DEPT
244. Consider a table EMPLOYEE with columns EMP_ID and SALARY with unknown number of
records. Write a query to extract top 25% of the records based on salary?
245. Consider a table EMPLOYEE with columns EMP_ID, DEPT_NO, and SALARY. Write a query to
extract all employees who have salaries higher than the avg. of their department.
246. Consider a table EMPLOYEE with columns EMP_ID and SALARY. Write a select query to output
a rank against each record. The rank must be based on the salary(rank 1 for the highest salary).
"Get the answer to all questions at the same rate as ordering a burger!"