clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3799418 fiddles created (41688 in the last week).

select 'User 1' sendingUser, 'User 2' ReceivingUser, Cast('08/01/2021' as date) [timestamp] into t union all select 'User 3', 'User 4', '08/01/2021' union all select 'User 2', 'User 1', '08/01/2021' union all select 'User 1', 'User 2', '08/02/2021' union all select 'User 3', 'User 4', '08/02/2021' union all select 'User 1', 'User 2', '08/03/2021'
6 rows affected
 hidden batch(es)


select sendinguser, ReceivingUser, Count(*) MessageCount from t where timestamp between '20210801' and '20210831' group by sendinguser,ReceivingUser order by sendinguser
sendinguser ReceivingUser MessageCount
User 1 User 2 3
User 2 User 1 1
User 3 User 4 2
 hidden batch(es)