Large Case Statement

Reply
Highlighted
Green Belt

Large Case Statement

I have a large case statement (45 lines) that groups similar advertising campaigns together. It's used because the same campaigns are run across multiple states. The statement is too big to use in a Beast Mode, so I'm wondering if someone can help me write the MySQL to do this in a Dataflow.

 

I tried something like

 

select * from google_adwords where `Campaign` = 'Campaign A' as 'Campaign A'

But I'm not good with manipulating datasets with MySQL. Any help would be appreciated.


Accepted Solutions
Highlighted
Major Brown Belt

Re: Large Case Statement

i would use a CASE statement instead. something like this

 

select *,

case when Campaign = 'Campaign A' then 'Result1'

case when Campaign = 'Campaign B' then 'Result1'

case when Campaign = 'Campaign C' then 'Result1'

case when Campaign = 'Campaign D' then 'Result2'

case when Campaign = 'Campaign E' then 'Result2'

case when Campaign = 'Campaign F' then 'Result2'

....

Else Campaign

End as Grouping

from google_adwords

Domo Arigato!

**Say 'Thanks' by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as 'Accepted Solution'

View solution in original post


All Replies
Highlighted
Major Brown Belt

Re: Large Case Statement

i would use a CASE statement instead. something like this

 

select *,

case when Campaign = 'Campaign A' then 'Result1'

case when Campaign = 'Campaign B' then 'Result1'

case when Campaign = 'Campaign C' then 'Result1'

case when Campaign = 'Campaign D' then 'Result2'

case when Campaign = 'Campaign E' then 'Result2'

case when Campaign = 'Campaign F' then 'Result2'

....

Else Campaign

End as Grouping

from google_adwords

Domo Arigato!

**Say 'Thanks' by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as 'Accepted Solution'

View solution in original post

Announcements
Coming Soon: Weekly Virtual User Meet-ups to answer all your questions! Stay tuned for more details to come this week.