10+ Top-Asked SQL Interview Questions & Answers 2018 (Updated)

Here we have covered 15 mostly asked SQL Interview Questions that many of the interviewers asked at the time of the interview. Not only for fresher, but these Questions and Answers are useful for experienced candidates.

SQL Interview Questions

Suggested Read: Excel Interview Questions

SQL Interview Questions

1. What are the different types of statements that SQL supports?

Ans. DDL statement: This is the Data Definition Language that defines the structure of the database like tables. This consists of three statements including Create, Alter, and Drop.

Create: The command is used to create a table.

Alter: The command is used to modify the existing table in the database.

DML statement: This is the Data Manipulation language which is used to make changes in the data present in the records. Commands such as Insert, Update, and Delete are the DML statements.

DCL statement: This is Data control language which is used to set privileges so that the user can enjoy database access permission assigned to the user.

2. Define different clauses in SQL?

Ans. Where Clause: This clause defines the condition that extracts and displays records who met the specific condition.

Group By Clause: You can use this clause with a SELECT statement and group the result using the specified value. The clause matches the value with column name and groups the result accordingly.

Order By clause: The query defines the order as output either in ascending or descending order.

Using Clause: The clause is useful while you started working with SQL joins. With this command, you can check the equality of the columns when you join tables.

Having Clause: The clause is associated with Group By clause and is applied to every group much similar to the WHERE clause.

3) What is the use of a truncate command?

Truncate is the DDL command which works quicker than DELETE command. The Truncate command does not store data in rollback gap. The command will not recover the deleted data. You can use any condition via Where clause. This is not possible with TRUNCATE command. You cannot run trigger using TRUNCATE command whereas with DELETE command you can run trigger.

4) Define the SQL CASE statement with an example?

The case statement performs the If-Else condition. In the select clause, you can embed the CASE statement. For example,

SELECT employee_name, CASE location

When ‘Alex’ Then Bonus*1.5

When ‘Shakti’ Then Bonus*2

Else Bonus


“NEW Bonus”


5) What is the SQL Profiler?

This is a graphical user interface that traces SQL for monitoring the Database Engine or analysis the services. This also helps in saving your data for every event and you can analyze it later.

6) Define Transaction and its different types of controls?

The transaction command has sequence task that can be performed on databases to get the result. In the transaction, you can create a database, update and delete records. The transaction consists of a group of queries that you can execute on the database.

COMMIT: In commit command, all the changes that you have made are saved via transaction.

SAVEPOINT: You can set the point as SAVEPOINT from where the transaction will be rolled back.

ROLLBACK: With this command, you can roll back the transaction i.e, all the changes made into the transaction are reverted back.

SET TRANSACTION: You can set the name of the transaction.

7) Define all the aggregate functions available in SQL?

The Aggregate function calculates values from multiple columns of any table and returns outcome as the single value. There are 7 different functions available in SQL:

  • COUNT(): The function returns the total number of rows.
  • LAST(): It returns the last value.
  • FIRST(): It returns the first value.
  • MAX(): The function returns the largest value.
  • MIN(): This return the smallest value.
  • SUM(): It returns the sum of all the columns.
  • AVG(): It returns the average value of all the columns.

 8) Define View in SQL?

The view is the virtual table consists of rows and columns having fields extracted from one or more columns


SELECT Name, Age

FROM Employee

Where Age>=20

9) What is the difference between SQL and MySQL?

The SQL is the structured query language that manipulates and accesses the relational database whereas MySQL is the relational database that considers SQL as the standard database language.

10) Define NVL function?

The NVL function converts the null value into the actual value.

11) What are the types of normalizations?

1NF: (First Normal Form)

  • This removes the duplicate columns.
  • It creates tables by doing identification of the unique columns.

2NF: (Second Normal Form)

  • Fulfill all 1NF requirements.
  • Create a relationship between tables via primary key.
  • Subsets are placed in the separate tables.

3NF: (Third Normal Form)

  • Meet all 2NF requirements.
  • Columns that are not dependant on primary key constraints must be removed.

4NF: (Fourth Normal Form)

  • Fulfill all 3NF requirements
  • Do not have multi-valued dependencies.

12) What are the constraints?

The constraints are used to denote the limit on table’s data type. You can specify constraints while creating and altering the table.

Primary key

Foreign Key



Not Null

13) What do you mean by ALIAS command?

Alias is the name which is given to a table or column. You declare alias in Where clause to denote the table or column. For example,

Select st.studentID, Ex.Marks from student st, exam ex where st.studentID = ex.studentID

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *