Support Questions
Find answers, ask questions, and share your expertise

How to create hive table with different columns as alias pointing to one column

New Contributor
 
1 REPLY 1

Super Collaborator

Hi @Dinesh Singh,

If I understand correctly you need to select value which ever has non null out of two columns,

for instance if your data has this manner.

Col1Col2
A1B1
NULLB2
A3NULL

and you would like to select the data as (A1,B2,A3) you may use COALESCE(Col1,Col2,'<Your Default value>')

and on top of this table you may create a view so that end user directly view the result as single columns

NB: If you are convenient you may use case statement for complex logic implementation to retrieve as single column.

Thanks,

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.