Skip to content

Tag: sql

Calculate number of watches by number of users in sql

I want to write 1 query that calculates the frequency buckets for each Ad. The frequency buckets would be the number of users who watched the Ad 1 time, 2 times, 3 times, etc. The table is: AdId UserID Watch Date 123 A 1/22 123 B 1/13 123 C 1/22 123 A 1/24 123 A 1/11 123 B 1/10 123

SQL with grouping sets returns the initial table

I have a sample table like this: name manager country position salary Mike Mark USA Content Writer 40000 Kate Mark France SEO Specialist 12000 John Caroline USA Outreach Expert 32000 Alice Caroline Italy SEO Specialist 50000 Philip Caroline Italy Marketing Manager 30000 Julia Caroline Italy SEO Specialist 440…