Write a query to identify the employee(s) whose salary is closest to the average salary of the company.

This question was asked in Interview at black rock. The open position had a CTC of 26 LPA. Read more Company: BlackRock CTC: 26LPA Source: LinkedIn SQL Interview Question Q. Write a query to identify the employee(s) whose salary is closest to the average salary of the company see this code on db-fiddle Solution Explanation In this … Read more

Display all months where sales exceeded the average monthly sales.

Display all months where sales exceeded the average monthly sales

This question was asked in Interview at black rock. Read more Company: BlackRock CTC: 26LPA Source: LinkedIn SQL Interview Question Q. Display all months where sales exceeded the average monthly sales see this code on db-fiddle Solution Solution 1 Solution 2 Explanation Although there are multiple ways to solve this problem, using the CTE method stands out … Read more

Find the most common value (mode) in a specific column.

This question was asked in Interview at black rock. Read more Company: BlackRock CTC: 26LPA Source: LinkedIn SQL Interview Question Q. Find the most common value (mode) in a specific column. See this code on db-fiddle Solution Explanation We have selected ProductName along with the count of rows as Frequency, grouping the data by ProductName. To display … Read more

Retrieve the name of the manager who supervises the most employees

Company: BlackRock CTC: 26LPA Source: Linked Post Q. Retrieve the name of the manager who supervises the most employees. Solution: Explanation: Here, we want to find out the manager who supervises the most employees. To achieve this, the query works in the following steps: Key Logic: Summary: The query counts how many employees each manager supervises, … Read more

Identify products that were sold in all regions.

Query: SELECT product_id FROM sales GROUP BY product_id HAVING COUNT(DISTINCT region_id) = (SELECT COUNT(*) FROM regions); Explanation: We need to find products that have been sold in all regions. This involves comparing the distinct regions a product appears in with the total number of regions available. Here’s how the query works step-by-step: Key Points: Example: … Read more

Exit mobile version