I have 3 tables:
CustomerID | PromotionDate
1111 | 01-01-2020
2222 | 03-06-2021
3333 | 05-07-2021
4444 | 09-10-2020
CustomerID | WorkID
1111 | aaaa
1111 | bbbb
2222 | cccc
2222 | dddd
2222 | eeee
WorkID | StartDate
aaaa | 01-01-2020
bbbb | 01-02-2021
cccc | 05-07-2020
dddd | 06-08-2021
eeee | 03-07-2022
I want to find the count of WorkIDs for each CustomerIDs where StartDate >= PromotionDate for that CustomerID.
So the result for the above sample should be:
CustomerID | Count
1111 | 2
2222 | 2
3333 | 0
4444 | 0
How to achieve this?