Reputation: 107
The following column gives me counts:
COUNT("COMPLIANCE"."CD_ALL"."ProductCode") As "Active Contracts"
However, I want to put the count totals into buckets. This is what I tried:
case when (COUNT("COMPLIANCE"."CD_ALL"."ProductCode")) between 0 and 10 then '10 or less',
case when (COUNT("COMPLIANCE"."CD_ALL"."ProductCode")) between 11 and 20 then '11-20',
and so on...
What am I doing wrong here?
Upvotes: 0
Views: 1927
Reputation: 1270081
I think you want a single case
expression:
(case when (COUNT("COMPLIANCE"."CD_ALL"."ProductCode")) <= 10 then '10 or less'
when (COUNT("COMPLIANCE"."CD_ALL"."ProductCode")) <= 20 then '11-20'
else 'That many!!!'
end) as count_bucket
Upvotes: 1