In order to find Initial Date and Initial Price for any Product, I have, for example:
FromDate ToDate ProdID Price
3/23 4/6 P1 $19.99
4/6 4/20 P1 $17.99
4/20 5/4 P1 $19.99
5/18 6/3 P1 $16.99
6/01 6/15 P1 $15.99
Currently, I'm finding Initial Date and Price by:
Load
ProdID,
Price As InitPrice,
Date(Min(FromDate)) As InitDate
From TableName
Group By ProdID, Price;
Now the requirement is, if there's a gap and we do not get data for a Product for an interval (in this case two weeks), Initial Date should be set to when data is sent after the gap.
In this case, Initial Date should be 5/18 (and not 3/23) since, product (P1) missed data from 5/4 to 5/18.
Is there a way to achieve this?