First we have our dummy data
CREATE TABLE persons(
person_id NUMBER GENERATED BY DEFAULT AS IDENTITY,
first_name VARCHAR2(50) NOT NULL,
last_name VARCHAR2(50) NOT NULL,
age NUMBER,
PRIMARY KEY(person_id)
);
insert all
into persons(person_id,first_name,last_name,age) values(1,'jose','alvarez',32)
into persons(person_id,first_name,last_name,age) values(2,'karla','romagnoli',24)
into persons(person_id,first_name,last_name,age) values(3,'daniela','alcazar',24)
into persons(person_id,first_name,last_name,age) values(4,'jaime','camilo',44)
into persons(person_id,first_name,last_name,age) values(5,'jenifer','paola',22)
into persons(person_id,first_name,last_name,age) values(6,'camila','puertas',55)
into persons(person_id,first_name,last_name,age) values(7,'raul','duelas',30)
into persons(person_id,first_name,last_name,age) values(8,'alejandra','bautizal',60)
into persons(person_id,first_name,last_name,age) values(9,'domingo','cano',16)
into persons(person_id,first_name,last_name,age) values(10,'felipe','vaca',25)
into persons(person_id,first_name,last_name,age) values(11,'estefany','santes',28)
into persons(person_id,first_name,last_name,age) values(12,'pamela','chu',55)
into persons(person_id,first_name,last_name,age) values(13,'fernanda','zarate',67)
select 1 from dual;
Since you only want one row with the data, plus the fact that those final results are not correlated to each other, we can integrate them with a cartesian product in this way:
select
q1.total as age20_30,
q2.total as age31_40,
q3.total as age50_60
from (
select count(*) as total from persons p
where p.age between 20 and 30
) q1, (
select count(*) as total from persons p
where p.age between 31 and 40
) q2, (
select count(*) as total from persons p
where p.age between 50 and 60
) q3 ;
And we get the next result
age20_30 |
age31_40 |
age50_60 |
6 |
1 |
3 |