Hi everyone.
I have this setup for my SELECT statement, where I get all payments * all times that a customer has accepted a campaign:
|customer.Customer ID| campaignImport.name | campaignImport.date | payment.id| payment.date |
|customer.Customer ID| campaignImport.name | campaignImport.date | payment.id| payment.date |
|customer.Customer ID| campaignImport.name | campaignImport.date | payment.id| payment.date |
Example:
|123| FirstCampaignID| 03-03-2021| Payment 1| 03-03-2021|
|123| FirstCampaignID| 03-03-2021| Payment 2| 04-04-2021|
|123| FirstCampaignID| 03-03-2021| Payment 3| 05-05-2021|
|123| FirstCampaignID| 03-03-2021| Payment 4| 06-06-2021|
|123| SecondCampaignID| 05-05-2021| Payment 1| 03-03-2021|
|123| SecondCampaignID| 05-05-2021| Payment 2| 04-04-2021|
|123| SecondCampaignID| 05-05-2021| Payment 3| 05-05-2021|
|123| SecondCampaignID| 05-05-2021| Payment 4| 06-06-2021|
As you can see, I have duplicate payments for each campaign.
I want to only get the payments between the CampaignImportDate and the next CampaignImportDate .
The result should be this:
|123| FirstCampaignID| 03-03-2021| Payment 1| 03-03-2021|
|123| FirstCampaignID| 03-03-2021| Payment 2| 04-04-2021|
|123| SecondCampaignID| 05-05-2021| Payment 3| 05-05-2021|
|123| SecondCampaignID| 05-05-2021| Payment 4| 06-06-2021|
Do you have any advice on how to do this?