Oracle SQL Developer - How to Display Percents using Color (Not Numbers)

Viewed 987

While working out of Oracle SQL Developer I came across a feature that I was unaware of until today. The feature is to display Percentages using colors not unlike how a horizontal bar chart could display the same percentages. I found it by right clicking on the connection and choosing the option 'Manage Database'.

Is this feature available for ANY query/report where percentages are being displayed? The column I'm referring to in the screenshot is the 'Percent_Used' column.

enter image description here

2 Answers

And here’s the code:

SELECT
    'SQLDEV:GAUGE:0:20000:1000:5000:' || peeps.salary "WhatIsItYoudSayYouDoHere",
    peeps.salary,
    peeps.first_name
    || ' '
    || peeps.last_name,
    peeps.job_id
FROM
    hr.employees peeps;

SQLDEV:GAUGE:0:200:50:150 equates to min:max:low threshold:upper threshold:value to graph

enter image description here

I am providing another example simplifying how to work with basic percents from 0 to 100 without using the Threshold options.

WITH fake_data AS
(
  SELECT 20  AS perc, 1001 AS entity FROM dual UNION ALL
  SELECT 30  AS perc, 1002 AS entity FROM dual UNION ALL
  SELECT 45  AS perc, 1003 AS entity FROM dual UNION ALL
  SELECT 100 AS perc, 1004 AS entity FROM dual UNION ALL
  SELECT 95  AS perc, 1005 AS entity FROM dual UNION ALL
  SELECT 33  AS perc, 1006 AS entity FROM dual UNION ALL
  SELECT 57  AS perc, 1007 AS entity FROM dual UNION ALL
  SELECT 70  AS perc, 1008 AS entity FROM dual UNION ALL
  SELECT 75  AS perc, 1009AS entity FROM dual UNION ALL
  SELECT 77  AS perc, 1010 AS entity FROM dual UNION ALL
  SELECT 85  AS perc, 1011 AS entity FROM dual UNION ALL
  SELECT 90  AS perc, 1012 AS entity FROM dual UNION ALL
  SELECT 94  AS perc, 1013 AS entity FROM dual UNION ALL
  SELECT 57  AS perc, 1014 AS entity FROM dual UNION ALL
  SELECT 60  AS perc, 1015 AS entity FROM dual UNION ALL
  SELECT 65  AS perc, 1016 AS entity FROM dual UNION ALL
  SELECT 80  AS perc, 1017 AS entity FROM dual
)

, stats AS
( /* Making it easy to adjust the values used by SQLDEV:GAUGE here as a single record. */
  SELECT 0 AS min_value, 100 AS max_value, 0 AS low_threshold, 0 AS upper_threshold FROM dual
)

SELECT
    'SQLDEV:GAUGE:'|| s.min_value
              ||':'|| s.max_value
              ||':'|| s.low_threshold
              ||':'|| s.upper_threshold
              ||':'|| fd.perc
      AS perc_visual
    /* SQLDEV:GAUGE:0:20000:1000:5000 equates to min:max:low threshold:upper threshold:value to graph */
    , fd.perc
    , fd.entity
FROM stats s, /* Single Record here so we can just use 'comma joins' here aka crappy old skool join syntax */
    fake_data fd
ORDER BY perc desc
;

enter image description here

Related