Select value into sql as column name

I have a drop down select and I am trying to get the user selected value into my sql as a dynamic value.

I am using mysql so trying to reference the column name around backticks.

eg

select
  max(date) as date,
  `{{ pivot_select.value }}`
  FROM
  general.retool_results_view
      where date >= {{ date_range.value.start.split('T')[0]  }}
  and date <= {{ date_range.value.end.split('T')[0]  }}
  group by `{{ pivot_select.value }}`

How would I do this?

Hey @BKM!

If you'd like to dynamically specify columns in your query you'll need to disable prepared statements is that something you've explored already?