Conditionally selecting which table to pull from
I'm having trouble finding answers on how to conditionally pull from a specific table, i.e. "select dimension, sum(metric1), sum(metric2) from case when dimension = '123' then [view1] else [view2] end group by dimension". Any ideas? Happy to clarify the question more if needed.
Hi Brien Jones ! Definitely an interesting question, case when statements cannot go into the from clause, but I wonder if your set up would fit into something with a union all... like so:
select dimension , sum(metric1) , sum(metric2) from [view1] where dimension = '123' group by dimension union all select dimension , sum(metric1) , sum(metric2) from [view2] where dimension != '123' group by dimension
Let me know if that would work for you here!Reply