Skip to content

Instantly share code, notes, and snippets.

@thanoojgithub
Last active May 29, 2018 08:01
Show Gist options
  • Save thanoojgithub/3de1adabca7f91dac704 to your computer and use it in GitHub Desktop.
Save thanoojgithub/3de1adabca7f91dac704 to your computer and use it in GitHub Desktop.
case when in Hive
hive> set hive.cli.print.header=true;
hive> select location,(case when doa is not null then concat(location,',',doa) when doa is null then location end ) as location_doa from thanooj.cust_credit;
OK
location location_doa
ayodhya ayodhya,2015-10-12
midhila midhila,2015-09-12
ayodhya ayodhya,2015-11-12
ayodhya ayodhya,2015-12-12
ayodhya ayodhya,2015-12-12
ayodhya ayodhya,2015-11-12
ayodhya ayodhya,2015-10-12
midhila midhila,2015-09-12
ayodhya ayodhya,2015-11-12
ayodhya ayodhya,2015-12-12
ayodhya ayodhya,2015-12-12
ayodhya ayodhya,2015-11-12
Time taken: 0.094 seconds, Fetched: 12 row(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment