Link to home
Start Free TrialLog in
Avatar of mehul bhakta
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
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mehul bhakta
mehul bhakta

ASKER

for some strange reason that wasn't giving me the results I was looking for, however I did find a good solution using

last_value(gender ignore nulls) over(partition by customer_id order by from_date rows between unbounded preceding and unbounded following)
cool. :)
@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.
a million thanks to Pawan