Sarah
Sarah

Reputation: 161

How to find the earlier date between two events?

I have the following table:

enter image description here

For each member from this table, I would like to get the event date. The event date should be pulled by comparing the event dates for "run" and 'jog" events and which ever date is smaller/earlier, that date is what i need.

So my output table will look like:

enter image description here

Upvotes: 0

Views: 68

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44951

Assuming event_date is of date type or at least a string in YYYY-MM-DD format (and it was changed in the Excel)

select      member
           ,min(event_date)
from        mytable
where       event in ('run','jog')
group by    member

Upvotes: 1

Related Questions