Currently working on a thesis where I have been tasked with aggregating data to a new table I'm trying to build out an aggregated table where I'll store each row group by date and a time interval (let's say 30 minutes). I came across store procedures and think that this would be the best solution. My source table is constructed as followed (StartDateTime = datetime2) ( StartDateTime Name ... Path 2021-02-28 20:23:43.1 Tom ... FG_T 2021-02-28 20:24:34.6 Tom ... LS_t --- --- ... --- 2021-02-28 20:35:09.5 Abby ... FS_t 2021-02-28 21:55:34.6 Tom ... FS_t 2021-XX-XX HH:MM:SS.s Abby ... XX My desire is to have an output table (must be a table I want to store it over time, not just temp) that counts the amount events that have happened within a given period, this procedure should be run once a day and create an entry for every available "timeslot" from the last 24h. PeriodStart Period(sek) Name Sum 2021-02-28 20:00:00.0 1800 Tom 2 2021-02-28 20:30:00.0 1800 Abby 1 2021-02-28 21:00:00.0 1800 NULL NULL 2021-02-28 21:30:00.0 1800 Tom 1 Could someone point me in the right direction on where I could find information about creating something like this? My thanks in advance from an aspiring SQL enthusiast :)