Answer the question
In order to leave comments, you need to log in
How to merge requests?
There are many similar queries like "SELECT COUNT(*) FROM ... WHERE ..." Is it possible to combine them into one query? To return an array of numbers COUNT. Those. the data is taken from the same table, the WHERE condition just changes. For example, take some kind of table like: Group(id, name, owner_id). And you need to take the type of all groups where the owner_id is equal to either 1 or 2 or 3. More precisely, take the number of such groups. You don't need to capture the data yourself.
Answer the question
In order to leave comments, you need to log in
select count(*) cnt from test
union all
select count(*) cnt from test2
interest Ask.
I would dig in the direction of data aggregation and my function
https://docs.djangoproject.com/en/1.10/ref/models/...
select '<10', count(id) from TBL where Id < 10
union all
select '=10', count(id) from TBL where Id = 10
union all
select '>10', count(id) from TBL where Id > 10
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question