Hi @Du Lu
Step1 : Collect all the dates between start date and end date as the campaign is happening on those dates.
Step2; Explode the collected date set
Step3: Count the number of campaigns happening on a particular date using a simple grouping expression.
Query looks something like this : (assuming startDate and EndDate are date columns and not strings. If strings, cast to date before proceeding).
select count(campaignName) as CampaignCount , EventDate from
( select campaignName, explode(sequence(StartDate, EndDate, interval 1 day)) as EventDate from source)
group by 2
If you want specific date range you can do that by adding a where clause in the above query.
select count(campaignName) as CampaignCount , EventDate from
( select campaignName, explode(sequence(StartDate, EndDate, interval 1 day)) as EventDate from source)
where EventDate between "2022-07-06" and "2022-08-03"
group by 2
Hope this helps...
Cheers.
Uma Mahesh D