Large Case Statement

Reply
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
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
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
Check out these great solution videos! The new iSolveditWithDomoboard is live, share yours and earn higher rankings in Dojo click here!