LeetCode – Consecutive Numbers
Question Write a SQL query to find all numbers that appear at least three times consecutively in the Logs table.Return the result in any order.… Read More »LeetCode – Consecutive Numbers
![]()
SQL Server Tutorials| Basics & Advance Concepts | Interview Question & Answer Series | SQL Server Tricks & Tips
Question Write a SQL query to find all numbers that appear at least three times consecutively in the Logs table.Return the result in any order.… Read More »LeetCode – Consecutive Numbers
![]()
Question Write a SQL query to report the first name, last name, city, and state of each person in the Person table. If a person’s… Read More »LeetCode – Combine two tables
![]()
Write a SQL query to: Find the top 2 highest-paid employees in each department. Show their ranking based on salary within the department. Also calculate… Read More »Finds the top two highest-paid employees in each department
![]()
SQL Exercise – Create a function that accepts a start date, an end date, and a day of the week (e.g., “Monday”). The function should return a table listing all dates within the specified range that match the given day of the week.
![]()
SQL Exercise: Retrieve a list of all tables along with the number of rows in each table in SQL Server. Soluton: To retrieve a list… Read More »SQL Exercise – 20
![]()
SQL Exercise: Retrieve the Top and Bottom 2 Sales Scenario: You have a SalesData table with the following columns: SalesID (unique identifier for sales records)… Read More »SQL Exercise – 19
![]()
SQL Exercise: You are given a table Numbers that contains a sequence of numbers starting from 1 to 10. But some numbers are missing. Your… Read More »SQL Exercise -18
![]()
SQL Exercise: You are given an Employee table containing details about employees, their departments, and their salaries. Your task is to write an SQL query… Read More »SQL Exercise – 17
![]()
SQL Exercise: Write an SQL query to calculate the percentage contribution to sales by each manager for a company. The data is stored in a… Read More »SQL Exercise -16
![]()
SQL Exercise: A company tracks sales data on a monthly basis and wants to calculate the percentage growth or decline in sales for each product… Read More »SQL Exercise – 15
![]()
SQL Exercise: Write a SQL query to classify invoices based on aging buckets: Due within the last 30 days: Due date is within the last… Read More »SQL Exercise -14
![]()
SQL Exercise: You are given a table of ticket data that includes the TicketID, OpenDate, and CloseDate. The task is to generate a new row… Read More »SQL Exercise – 13
![]()
SQL Exercise: You are provided with a table of employees containing their names, departments, and salaries. Write a query to determine the applicable tax rate… Read More »SQL Exercise – 12
![]()
SQL Exercise: You are given a table containing a list of departments and employees. Write a query to concatenate all employee names for each department… Read More »SQL Exercise – 9
![]()
SQL Exercise: Create a SQL function that takes a string as input and removes all special characters (keeping only alphanumeric characters and spaces). The following… Read More »SQL Exercise – 8
![]()
SQL Exercise: Given a table Sales that records sales data for various products across multiple months, write a query to dynamically pivot the data such… Read More »SQL Exercise – 11
![]()
SQL Exercise: You are provided with a table Sales that records monthly sales data for various products. Write a query to transform the data such… Read More »SQL Exercise -10
![]()
SQL Exercise: You are given two tables: Employees and Departments. Write a query to find the highest-paid employee in each department. If a department does… Read More »SQL Exercise – 7
![]()
SQL Exercise: Suppose you have a Sales table that tracks product sales data, including the sale amount, product category, and sale date. You want to… Read More »SQL Exercise – 6
![]()