Brilliant SQL Interview Question | Solve it without using CTE, Sub Query, Window functions

Опубликовано: 07 Октябрь 2024
на канале: Ankit Bansal
15,291
513

In this video we will discuss a SQL interview question. The challenging part with this question is we cannot use CTE, temp table, window functions and sub query. You will love the solution.

Most Asked Join Based Interview Question:
   • Most Asked SQL JOIN based Interview Q...  

Data Analyst Spotify Case Study:
   • Data Analyst Spotify Case Study | SQL...  

Top 10 SQL interview Questions:
   • Top 10 SQL interview Questions and An...  

Interview Question based on FULL OUTER JOIN:
   • SQL Interview Question Based on Full ...  

Playlist to master SQL :
   • Complex SQL Questions for Interview P...  

Rank, Dense_Rank and Row_Number:
   • RANK, DENSE_RANK, ROW_NUMBER SQL Anal...  

DDL:
CREATE TABLE [dbo].[int_orders](
[order_number] [int] NOT NULL,
[order_date] [date] NOT NULL,
[cust_id] [int] NOT NULL,
[salesperson_id] [int] NOT NULL,
[amount] [float] NOT NULL
) ON [PRIMARY];

INSERT INTO [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (30, CAST('1995-07-14' AS Date), 9, 1, 460);

INSERT into [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (10, CAST('1996-08-02' AS Date), 4, 2, 540);

INSERT INTO [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (40, CAST('1998-01-29' AS Date), 7, 2, 2400);

INSERT INTO [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (50, CAST('1998-02-03' AS Date), 6, 7, 600);

INSERT into [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (60, CAST('1998-03-02' AS Date), 6, 7, 720);

INSERT into [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (70, CAST('1998-05-06' AS Date), 9, 7, 150);

INSERT into [dbo].[int_orders] ([order_number], [order_date], [cust_id], [salesperson_id], [amount]) VALUES (20, CAST('1999-01-30' AS Date), 4, 8, 1800);

#sql #dataengineer