MySQL Forums
Forum List  »  Newbie

Re: Counting a number of dates in one column below another date in another column
Posted by: Peter Brawley
Date: October 14, 2020 08:37AM

One step at a time ...

1 Ensure the dates are actual mysql date values, not varchar values using the oddball US format that you show

2 Retrieve and count

select b.contract_end_date, count(a.task_date)
from tableA
join tableB on a.task_date < b.contract_end_date.
group by contract_end_date
order by contract_end_date;

But I suspect you've left something out of the requirement, for the logic you set out mushes together all referenced contracts, so it'll just show declining task_date counts as contract_end_date increases.

Options: ReplyQuote


Subject
Written By
Posted
Re: Counting a number of dates in one column below another date in another column
October 14, 2020 08:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.