Oracle
 sql >> Database >  >> RDS >> Oracle

JFreeChart utilizzando la query numerica ORACLE

Prova qualcosa del genere (Ecco un sqlfiddle ):

select case 
           when time >= 23 then '23 =< TIME'
           when time < 23 and time >= 22.3 then '23 > TIME >= 22,3'
           when time < 22.3 and time >= 21.6 then '22,3 > TIME >= 21,6'
           when time < 21.6 and time >= 20.9 then '21,6 > TIME >= 20,9'
           else '20,9 > TIME'
        end   || ' with value '|| count(*) v
from your_table
group by case 
           when time >= 23 then '23 =< TIME'
           when time < 23 and time >= 22.3 then '23 > TIME >= 22,3'
           when time < 22.3 and time >= 21.6 then '22,3 > TIME >= 21,6'
           when time < 21.6 and time >= 20.9 then '21,6 > TIME >= 20,9'
           else '20,9 > TIME'
         end 

e i risultati:

21,6 > TIME >= 20,9 with value 8 
20,9 > TIME with value 4 
22,3 > TIME >= 21,6 with value 6 
23 > TIME >= 22,3 with value 15 
23 =< TIME with value 66

AGGIORNAMENTO: Come suggerito da DavidAldrige, puoi avere una sottoquery:

select intrvl || ' with value '|| count(*) v
from
(select case 
           when time >= 23 then '23 =< TIME'
           when time < 23 and time >= 22.3 then '23 > TIME >= 22,3'
           when time < 22.3 and time >= 21.6 then '22,3 > TIME >= 21,6'
           when time < 21.6 and time >= 20.9 then '21,6 > TIME >= 20,9'
           else '20,9 > TIME'
        end   intrvl, time
from t)
group by intrvl

Ed ecco un'altra demo