mehul bhakta
asked on
find the min start date each time
hello community,
I was wondering if there was a way to find the earliest start date per product at a premise.
If you can see in the spreadsheet attached is a sample customer. This premise_id was supplied to 3 tenants, The last tenant left supply and then came back so I'd want another start date for that product at that premise. highlighted in yellow are the dates I want to find using SQL. bare in mind a customer could have multiple fuels at a premise however they are split by account_reference.
is there a way to do this?
Thank you all, hopefully that was a good enough description into what I am trying to do.
sample.xlsx
I was wondering if there was a way to find the earliest start date per product at a premise.
If you can see in the spreadsheet attached is a sample customer. This premise_id was supplied to 3 tenants, The last tenant left supply and then came back so I'd want another start date for that product at that premise. highlighted in yellow are the dates I want to find using SQL. bare in mind a customer could have multiple fuels at a premise however they are split by account_reference.
is there a way to do this?
Thank you all, hopefully that was a good enough description into what I am trying to do.
sample.xlsx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
cool. :)
ASKER
@Pawan Kumar thank you sooooo much for your time and help. you have no idea how much I appreciated your help and this website.
welcome. glad to help as always.
ASKER
a million thanks to Pawan
ASKER
last_value(gender ignore nulls) over(partition by customer_id order by from_date rows between unbounded preceding and unbounded following)