Declaring local variables in the dialog editor for SQL

Dear App Builders,

in my sql queries I frequently use variables or filter.values to conditionally output results. In some cases I use the same variables/filter.values multiple times in the same query. Is there a way to declare local variables in the dialog editor for SQL before using those? I tried it but only got errors.

See example:

CASE
    WHEN (
      '{{filters.HIDDENFILTER_currentUserValue__HIDDENFILTER_currentUserValue_CONTAINER.current_user_value.values[0]}}' = 'false'
      OR {{VARIABLE_userRole}}
    )
    AND status = 'xyz' THEN 'BUTTON_xyz'
    ELSE 'BUTTON_HTML_backToOverview'
  END AS primary_action_button,

Thanks for the answers :slight_smile: