A community member has associated this post with a similar question:
Sum of different date by id
Only moderators can edit this content.
Date Duration by ID
Hi Expert,
I wanted to calculate max date for prodstatus =5 - min date for prodstatus=4 and max date for prodstatus =6 - min date for prodstatus=5
Create table
CREATE TABLE [dbo].testdata ON [PRIMARY]
GO
Insert
insert into [dbo].[testdata]
values('Prod1000','873','7','2021-06-16', '11-05-2022', '4'),
(' ','873', '18', '2022-05-12',NULL,'7'),
('Prod1000', '873', '19', '2022-05-12', '28-06-2022','5'),
('Prod1000', '1254','4', '2022-06-29', '2022-07-30', '6'),
('Prod1000', '1254','4', '2022-07-30', '2022-08-30', '7'),
expected output