Most frequently asked SQL Interview Questions

RDBMS is the most extensively used database management system. Therefore, there is a high demand for the individuals who possess SQL skills. So it is highly essential to refer to the frequently asked SQL Interview Questions, if you want to land your dream job!

Do check out our Free Course on SQL Great Learning Academy. In this blog, we shall start with most frequently asked basic SQL Interview questions. Then, we shall move to most frequently asked SQL Queries.

1. What is a database?

Database is the systematic collection of data which supports storage and manipulation of data which supports storage and manipulation of data in an easy way.

2. What is the major difference between the “WHERE” clause and the “HAVING” clause?

WHERE clause is used with a Select, Update and Delete Statement Clause. The HAVING clause is  used only with a Select statement.

 3. What is the major difference between the “DELETE” and “TRUNCATE” commands?

The DELETE command removes rows from a table based on a WHERE condition and TRUNCATE removes all rows from a table.

4. What is the major difference between “Primary Key” and “Unique Key”?

There should be only one Primary Key in a table whereas we can have more than  one Unique Key in a table.

The Primary Key cannot have a NULL value but an Unique Key may have only one null value.

 5. What are the main differences between DDL, DML and DCL in SQL?

  Following are some details of three.

DDL -Data Definition Language. SQL queries like CREATE, ALTER, DROP and RENAME belongs to this.

DML – Data Manipulation Language. SQL queries like SELECT, INSERT and UPDATE belongs to this.

DCL – Data Control Language. SQL queries like GRANT and REVOKE belongs to this.

6.  What is Join in SQL?

 SQL Join combines the data from two or more tables based on a common field between them. For example, consider the following two tables.

Student Table


StudentCourse Table



The below query shows names of students enrolled in different courseIDs.

SELECT StudentCourse.CourseID, Student.StudentName FROM StudentCourse

INNER JOIN Customers

ON StudentCourse.EnrollNo = Student.EnrollNo ORDER BY StudentCourse.CourseID;

The above query would produce the following result.


7. What are the different types of SQL or different commands in SQL? 

  1. DDL – Data Definition Language. DDL defines the structure that holds the data.
  1. DML– Data Manipulation Language

DML manipulates the data itself.  Operations performed are Insert, Delete, Update and retrieving the data from the table

  1. DCL–Data Control Language

DCL  controls  the visibility of data like granting database access and set privileges to create tables etc.

     4.TCL– Transaction Control Language

      These are used to manage transactions in the database.

8. What are Aggregate Functions  in SQL?

They perform a calculation on a set of multiple values and return a single value. Aggregate functions ignore NULL values but COUNT functions. HAVING clause is used with GROUP BY for filtering query using aggregate values.

9. What is meant by constraints?

     Constraints enforce integrity of the database. Constraints can be of following types 

     Not ,Null



    Primary key

    Foreign key

10.Define stored procedure in SQL?

Stored procedure is a set of pre-compiled SQL statements which is executed when it is called in the program.

11. Define Trigger in SQL?

Triggers are the same as  stored procedures but it is executed automatically when any operations occur on the table.

12. What are data types in My sql ?

A data type defines the type of data that the object can hold. Some of them are integer data, character data, time and date data, monetary data, binary strings and so on.

13.What are the types of subquery in SQL?

     1. Nested subquery 

     2. Correlated subquery 

14. What is Alias concept ?

     It is a concept used in SQL to give temporary names to the table or the column of the table.

15. Which is the most used DBMS software ?

  • My SQL
  • Oracle
  • PostgreSQL
  • SQLite
  • Maria DB


  1.  Find the second highest salary of an Employee by using SQL query?

 There are many ways to find the second highest salary of Employee in SQL. You can either use SQL Join or Subquery to solve this problem. Here we are solving using SQL using Subquery:

2. Write an SQL Query to find Max Salary from each department?

3.Write an SQL Query to display the current date in SQL?

   SQL has a built -in function called GetDate() which returns the current time.

4.Write an SQL Query to check whether the date passed to the Query is the date of the given format or not?

   SQL has IsDate() function which  checks if the passed value is date or not of specified format, it returns 1(true) or 0(false) accordingly.

5. Write an SQL Query to find the name of an employee whose name Start with ‘L’?

  6. Write an SQL Query to find an employee whose Salary is equal or greater than 10000?

  SELECT EmpName FROM Employees WHERE Salary>=10000;

7. Select all records from the employee table where departmentno =10 or 40.

select * from employee where departmentno=30 or departmentno=10;

8.Select all records from employee table where departmentno=30 and sal>1600.

select * from employee where departmentno=30 and sal>1600;

99. Select all records from the employee table where the job is not in SALESMAN or CLERK.

select * from employee where job not in (‘SALESMAN’,’CLERK’);

10.Select all records from the employee where empname in ‘BLAKE’,’SCOTT’,’KING ‘and ‘FORD’.

select * from employee where ename in(‘JONES’,’BLAKE’,’SCOTT’,’KING’,’FORD’); 

11. Select all records where ename starts with ‘L’ and its length is 6 char. 

select * from employee where ename like ‘L ‘;

With this, we are at the end of the blog on the top SQL Interview Questions. We hope that you were able to gain valuable insight into SQL from the same. Good luck on your upcoming interview.