Kayla Rice
Kayla Rice

Reputation: 31

Conditional formatting (red text) in Oracle Apex SQL

Using Oracle APEX, I am working with Salary data. I would like to make all salaries >= $100,000.00 display with red text. How can I do this directly in my code?

Table name is OEHR_EMPLOYEE and Column name is Salary

Upvotes: 3

Views: 2202

Answers (2)

Imran
Imran

Reputation: 169

select  empno,
        fname,
        case 
            when sal >= 100000 then '<span style="color:red">'||sal||'</span>'
            else sal
        end as salary
from emp

Going to Salary Column > Security > Escape special charactters : No

Upvotes: 0

Littlefoot
Littlefoot

Reputation: 142720

In query? Something like this:

select case when salary >= 100000 then '<span style="color:red">' || to_char(salary) || '</span>'
            else to_char(salary)
       end as salary
from oehr_employee
where ...

Don't forget to set column's "escape special characters" property to "No".

Example (a classic report) created on Scott's EMP table (I painted salaries higher than 2000):


Additionally, it is an interactive report, go to Actions button and conditionally paint salaries higher than 100.000 - it is easier, and even end users can modify it if they want to.

Upvotes: 5

Related Questions