PMC ANALYTICS INTERVIEW QUESTION - Retrieve start date and end date based on the sequential data


DROP TABLE IF EXISTS Schedule


CREATE TABLE Schedule

(

Task_ID INT,

[Start_Date] DATETIME,

[End_Date] DATETIME

)


INSERT INTO Schedule

VALUES 

(1,'2023-10-01','2023-10-02'),

(2,'2023-10-02','2023-10-03'),

(3,'2023-10-03','2023-10-04'),

(4,'2023-10-13','2023-10-14'),

(5,'2023-10-14','2023-10-15'),

(6,'2023-10-28','2023-10-29'),

(7,'2023-10-30','2023-10-31') 



SELECT * FROM Schedule


Expected output:

 --Output


--2015-10-28 2015-10-29

--2015-10-30 2015-10-31

--2015-10-13 2015-10-15

--2015-10-01 2015-10-04


Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs