9 Frequently Asked SQL Queries Interview Questions (2019)

sql queries interview questions

If you are familiar with Java Interview questions, then you can continue with the following post.

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 the 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 the 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 a 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 the database
  • Insert data or rows in the database
  • Delete data from the database
  1. What is the data definition language?

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

Please do discuss below if you find any impropriate, or you please do share more information about the topic discussed above.