Database

In this post, I have listed Database SQL Queries Interview questions. These SQL queries are really important from interview point of view.
These SQL  Queries covers most of the database concepts and these SQLs  are more frequently interview asking questions

SQL Query to find total employees department-wise(include department with zero employees)?

Let’s say I want to get department name and total employees count in each department (include department with zero employees) and sort employees count in ascending order?

SQL query to find average salary department wise?

Get department no and average salary

Get department no, department name and average salary

Get department no, department name and average salary(sort average salary in ascending/descending order

 

SQL Query to find 2nd highest salary of employee?

SQL Query to get 2nd highest salary

 

SQL Query to get 3rd highest salary

 

SQL Query to find the Nth highest salary of an employee?

To get 2nd Highest salary to replace N with 2 and to get 3rd Highest salary to replace N with  3 etc…..

Below are the SQL queries to get 2nd/3rd highest salary:

2nd Form of SQL query to get Nth Highest salary is:

Here to get 2nd highest salary to replace N with 2, To get 3rd highest salary to replace N with 3 etc…

 

 

SQL Query to find Nth highest salary in Oracle using ROW_NUMBER() function?

To get first/second/3rd/4th etc…   highest salary replace N with 1,2,3,4 etc…

Here N = 1,2,3,4…

For Example, to get 2nd highest salary below is the SQL Query:

SQL Query to find Nth highest salary in Oracle using DENSE_RANK() function?

To get first/second/3rd/4th etc…   highest salary replace N with 1,2,3,4 etc…

Here N = 1,2,3,4…

For Example, to get 2nd highest salary below is the SQL Query:

 

Find Nth Highest Salary Using RANK() Function?

Put N = 1,2,3,4,…etc to get 1st/2nd/3rd/4th ..highest salary in blow SQL query

 

SQL query to find duplicate rows in the table?

 

SQL query to create a table with the same structure of the Existing table?

 

SQL query to create a table with the same structure with data of the Existing table?

NOTE: In WHERE  Clause you to provide any false condition like 1=2 or 1=10, ‘A’ = ‘B’ 

 

Create SQL Query to get information of Employee where Employee is not assigned to the department?

How to fetch all the records from Employee whose joining year or month or day is given?

 

SQL Query to find all Employees with its managers?

 

How to display  Number from 1 to Given limit with a SQL query?

SQL Both Queries display numbers from 1 to 60 :

 

SQL Query to list deptno, dept name for all the departments in which there are no employees?

 

 

How to write SQL Query to get a total salary from salary and commission?

 

SQL Query to Find the Joining date of Employee in YYYY-MON-DD format?

 

Write a SQL Query to find the maximum salary of each department?

get get deptno,dname &  max salary department wise:

get deptno,dname &  max salary department wise and sort max salary in ascending order:

Write SQL Query to get Total Salary department wise where more than 5 employees exist?

 

SQL query to increase salary by 20 percent for all employees in department number 10 and 20?

 

SQL Query to find the Nth minimum salary of employees?

Put N= 1,2,3,4… to get first/second/3rd/4th… minimum salary

For Example to get 3rd minimum salary

To get 4th minimum salary

Selecting ODD or EVEN rows from a table in Oracle-explained two methods?

SQL query to find the total salary department wise?

SQL query to find total salary department wise and sort total salary in ascending/descending order?

SQL query to find the total salary department wise and their total salary is greater than 10000?

.SQL query to find the total number of employees in each department?

SQL to find departments whose the number of employees is greater than 4?

You May Also Like:

Introduction to Hibernate 5
Latest hibernate distribution Zip file download link
Hibernate 5 distribution binary details
Create SessionFactory in Hibernate5 using hibernate.cfg.xml
Create SessionFactory in Hibernate5 without hibernate.cfg.xml
Save and persist an entity example in hibernate
Hibernate CRUD(Create,Read,Update and Delete) example
Dirty checking in hibernate example
Understanding hibernate Configuration File
Why to use hibernate dialect?
Hibernate hbm2ddl property
What are the benefits of using hibernate?

That’s all about Database SQL Queries Interview questions
If you have any feedback or suggestion please feel free to drop in below comment box.