9 Frequently Asked SQL Queries Interview Questions

In this post, we have listed 9 frequently asked SQL queries interview questions with answers. This list can be usefulĀ for freshers as well as experienced candidates.

  1. What is SQL?

SQL or Structured Query Language is a language used in programming and designed for managing data held in a relational database management system.

  1. What are tables in SQL?

The table is a collection of record and its information at a single view.

  1. What is the SQL Query to find second highest salary of Employee?

There are various methods of finding second highest salary of Employee in SQL. You can either use SQL Join or Subquery to find the answer. Take a look at this SQL query using Subquery:

  1. How do you write an SQL Query to print the name of the distinct employee whose DOB is between 01/01/1960 to 31/12/1975?

Here you can use BETWEEN clause to get all records whose date fall between two dates.

  1. What is the SQL Query to find Max Salary from each department?

You can find the maximum salary for each department by grouping all records by DeptId and then using MAX() function to calculate the maximum salary in each group or each department.

  1. Write SQL Query to display the current date.

There is a built-in function in SQL called GetDate() which returns the current timestamp. This will work in Microsoft SQL Server, other vendors like Oracle and MySQL also has equivalent functions.

  1. What is the difference between CHAR and VARCHAR2 datatype in SQL?

Char is used for character strings of fixed length while varchar2 is used for character strings of variable length.

  1. What do you mean by data manipulation language?

DML or Data manipulation Language is used to access or manipulate data in the database.

It allows us to perform the following functions:

  • Retrieve or fetch data
  • Update data in database
  • Insert data or rows in database
  • Delete data from database
  1. What is data definition language?

Data definition language or DDL is used to execute queries like CREATE , ALTER and DELETE.


Leave a Reply

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