Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Most databases support some flavor of the SQL case statement making it easy to condition modify what appears in a column. This will show how to combine this article illustrates the process of combining a case statement with Confluence capabilities like macros to improve how enhance the way information is displayed.

...

Using

...

emoticons

This example uses emoticons to visually indicate some aspect aspects of the data this is import imported to highlight to the viewers.

  • Use a standard sql-query macro accessing SQL Query macro to access your data source containing that contains the data you want to query.
  • Use wiki for the Output format parameter.
  • The SQL will use utilizes a case statement. This In this example uses we use Postgres, but other database will be similarbut other databases will require similar case statements. Consult your database documentation's case statement for more details.
Code Block
languagesql
titleSQL
select 
     "Product",
     "Plan",     
     "Revenue",
     case 
         when "Revenue" >= "Plan" then '(/)'
         else '(x)'
     end as "Met Plan"
 from products

...

Using

...

macros

This example uses a Confluence macro to add visual indicators to the displaypointers.

  • Use a standard sql-query macro accessing SQL Query macro to access your data source containing that contains the data you want to query.
  • Use wiki for the Output format parameter.
  • The SQL will use utilizes a case statement. This In this example uses we use Postgres, but other database will be similarbut other databases will require similar case statements. Consult your database documentation's case statement for more details.
Code Block
languagesql
titleSQL
select 
     "Product",
     "Plan",      
     case 
         when "Revenue" >= "Plan" then '{color:green}*' || "Revenue" || '*{color}'
         else '{color:red}*' || "Revenue" || '*{color}'
     end as "Revenue"
 from products

Image Added