Home > front end >  Duplicate a row based in a column that has 2 values in spark sql
Duplicate a row based in a column that has 2 values in spark sql

Time:12-14

I have a temporary view that looks like this.

ID   Activity
1    Yes           
2    Yes
3    No
4    Yes

What I want is to duplicate a row by adding an 'All' value to Activity

Expecting result would be:

ID   Activity
1    Yes           
2    Yes
3    No
4    Yes
1    All
2    All
3    All
4    All

I tried to create it through Zeppelin, but I am not able to update a view.

Is there any way to do it please ?

I can only use SQL unfortunately

Thanks in advance for your help

CodePudding user response:

You can use union

select Id, Activity
from view

union all

select Id, 'All'
from view
  • Related