---
title: "How to use SQL case statement to improve the visual appeal"
canonical: "https://support.appfire.com/space/SUPPORT/89138455/How%20to%20use%20SQL%20case%20statement%20to%20improve%20the%20visual%20appeal"
format: markdown
---
> Macro (div)
> 
> ### <span style="color: #000000">On this page</span>
> 
> > Macro (toc)

## <span style="color: #000000">Description</span>

<span style="color: #000000">Most databases support some flavor of the SQL case statement making it easy to modify what appears in a column. This article illustrates the process of combining a case statement with Confluence capabilities like macros to enhance the way information is displayed.</span>

## <span style="color: #000000">Using emoticons</span>

<span style="color: #000000">This example uses emoticons to visually indicate some aspects of the data imported to the viewers.</span>

- <span style="color: #000000">Use a standard </span>*<span style="color: #000000">SQL Query</span>*<span style="color: #000000"> macro to access your data source that contains the data you want to query.</span>
- <span style="color: #000000">Use </span>*<span style="color: #000000">wiki</span>*<span style="color: #000000"> for the </span>*<span style="color: #000000">Output format</span>*<span style="color: #000000"> parameter.</span>
- <span style="color: #000000">SQL utilizes a case statement. In this example, we use Postgres but other databases can require similar case statements. Consult your database documentation's case statement for more details.</span>

##### **SQL **

```sql
select 
     "Product",
     "Plan",     
     "Revenue",
     case 
         when "Revenue" >= "Plan" then '(/)'
         else '(x)'
     end as "Met Plan"
 from products
```

![image](media://b673b0f7-d2c1-41e5-9791-6ff98ec5edd9)

## <span style="color: #000000">Using macros</span>

<span style="color: #000000">This example uses a Confluence macro to add visual pointers.</span>

- <span style="color: #000000">Use a standard </span>*<span style="color: #000000">SQL Query</span>*<span style="color: #000000"> macro to access your data source that contains the data you want to query.</span>
- <span style="color: #000000">Use </span>*<span style="color: #000000">wiki</span>*<span style="color: #000000"> for the </span>*<span style="color: #000000">Output format</span>*<span style="color: #000000"> parameter.</span>
- <span style="color: #000000">SQL utilizes a case statement. In this example, we use Postgres but other databases can require similar case statements. Consult your database documentation's case statement for more details.</span>

##### **SQL **

```sql
select 
     "Product",
     "Plan",      
     case 
         when "Revenue" >= "Plan" then '{color:green}*' || "Revenue" || '*{color}'
         else '{color:red}*' || "Revenue" || '*{color}'
     end as "Revenue"
 from products
```

![image](media://a198aa2b-e66c-4bff-8f8a-c50827c9568b)