I'm trying to do a Case-statment in postgres to do different things depending on if a column exist or not,
CASE
WHEN select exists (select * from information_schema.columns where
table_name = 'mytable' and column_name = 'mycolumnt')
THEN select mycolumn from mytable where mycolumnt = true
ELSE select mycolumn from mytable
END
After executing the case statement I got below error
ERROR: syntax error at or near "case"
Any tips what I'm doing wrong? My postgres-knowledge is pretty basic.