I am trying to simplify a set of queries into one with which I am afraid.
I want to collect counts of different ranges and am doing it right now:
select count(*) from items where value < 0 and id = 43;
select count(*) from items where (value >= 0 AND value <= 10) and id = 43;
select count(*) from items where (value > 10 AND value <= 20) and id = 43;
select count(*) from items where (value > 20 AND value <= 30) and id = 43;
select count(*) from items where value > 30 and id = 43;
I want to be able to do this in one request. How can i do this?
I also need each individual request to be counted, and not just them together.
source
share