Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

mysql - Combining multiple columns into one new column, while keeping the original column

I have below table, where I am trying to merge the columns in yellow in one column, while maintaining the original columns; the data in the highlighted yellow columns is populated based on the interaction type they fall into if the interaction type is null that means it doesn't fall into the interaction type category:

Would appreciate any help or guidance on how I can approach this

enter image description here

Expected outcome: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This looks like coalesce():

select t.*,
    coalesce(
        svc_proc, 
        interest, 
        transtypekey, 
        connectivity_name, 
        vm_entreprise_program,
        channels
    ) as interaction_details
from mytable t

coalesce() returns the first non-null value of the arguments list.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...