select i, coalesce(lpad('*', count(s), '*'), ' ') from (
select trunc(salary, -3) s from
employees
) stat right join
(select level*1000 i from dual connect by level <= 25) r
on r.i = stat.s
group by i
order by i
resultat:
1000
2000 ************************
3000 ******************
4000 *******
5000 *
6000 **********
7000 ***********
8000 *********
9000 ********
10000 ******
11000 ****
12000 ***
13000 **
14000 *
15000
16000
17000 **
18000
19000
20000
21000
22000
23000
24000 *
25000