Using If/Then construct in SQL
Use case
You have a table with the stationary orders. You need to output a new column in the table with the order priority according to the total sum of money: less than $1000 is Low, from $1000 to $2000 is Medium, and more than $2000 is High.
Solution
- Switch the page to the edit mode.
- Insert the Table Transformer macro and paste the table or the macros outputting tables within the macro body.
- Select the macro and click Edit.
- In the Presets tab select Custom transformation and click Next.
Enter the following SQL query:
SQLCASE WHEN ... THEN ... ELSE ... END goes through conditions and return a value when the first condition is met.
AS '...' outputs a new 'Priority' column.- Click Next.
- Define the table settings and view options if needed.
- Save the macro and the page.