{% set payment_methods = ['credit_card', 'coupon', 'bank_transfer', 'gift_card'] %}
...
{% for payment_method in payment_methods -%}
sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount,
{% endfor -%}
...
glue:
payment_methods <- c('credit_card', 'coupon', 'bank_transfer', 'gift_card')
glue("sum(case when payment_method = '{payment_methods}' then amount else 0 end as {payment_methods}_amount,")
Jinja:
glue: