I'm trying to count the number of customers that bought more than 10 items from a store a specific month that bought less than 10 items from the previous month (only has 2 months, 01 and 02)
For example,
id items_bought month
0001 11 02
0001 9 01
0003 8 02
0003 8 01
0005 13 02
0006 16 02
0006 17 01
this would return a count of 1.
My idea was to do a case statement like
case
when (month = '02' and items_bought > 10) and (month = '01' and items_bought < 10) then 1
else 0
end as c
and then kind of do a select c, count(c) where c = 1
but then I realized this wouldn't help since I would need to group by ids' and I'm kind of stuck where to continue.