I have a tableA
with different values:
data
------
10
15
20
40
40000
50000
60000
Also, I need to get some statistic information on that data (and I want to do it in one query), for example:
select count(data) from tableA where data < 100
union all
select count(data) from tableA where data >= 100
As result, I receive
(No column name)
----------------
4
3
But I want to receive results in one row, like this:
Small | Big
---------
4 | 3
How to do it? Is it possible?
select count(case when data < 100 then 1 end) as Small,
count(case when data >= 100 then 1 end) as Big
from TableA
With average it would look like this.
select avg(case when data < 100 then data end) as Small,
avg(case when data >= 100 then data end) as Big
from TableA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With