SQL Queries Interview Question

SQL Interview Question

SQL Interview Question Welcome to My Tutorial Scan! in this post we will see the most commonly asked structured query language (SQL) queries in interviews. Firstly we start with very basic questions and then move to more complex SQL Interview questions.

Firstly we are taken two tables and understand the table structure and let’s see what’s question will be generated from the table.

Table: EmployeeDetail                                                                                                      

SQL Queries Interview Question image

Table: EmployeeSalary

SQL Queries Interview Question image

SQL Queries Interview Question

1. Calculate the Count of Employees working on project P2?

Answer: Here, I will use count() function with the SQL where clause-

2. How will be calculated those Employee Name whose having a salary greater than or equal to 38000 and less than 30000?

Explanation: First, we will use BETWEEN in the ‘where’ clause to return the empId of the employees with salary and then use it as a subquery to find the Name of the employee form EmployeeDetail table.

3. How to fetch and write a SQL query to a project-wise count of employees sorted by project’s count in ascending order.

Explanation: first to fetch the project-wise count from EmployeeSalary Table and then to sort the result by that count For project wise count, and using GROUP BY clause for sorting, and use ORDER BY clause on the alias of the project-count.

 

 

Resource
w3school