Query to create new data column with alphabetical concatenating the data

  Kiến thức lập trình

How can I get result like OUTPUT table to be queried from original table

Original Table

clsID   stdID   c1      c2      c3      c4      

cls1    10      HE      HQ      UA      NULL    
cls1    11      HQ      H1      UA      NULL    

cls2    20      HG      AB      NULL    NULL    
cls2    21      H2      HQ      UA      NULL    
cls2    22      NULL    HQ      UA      NULL    

cls3    30      HG      AB      NULL    NULL    
cls3    31      HQ      GH      UA      NULL    
cls3    32      NULL    HQ      UA      NULL    
cls3    33      NULL    null    null    NULL

in my out put query I need to concatinate the columns stdId, c1,c2,c3,c4 and keep the new value as new column concatinatedvalue

Output TABLE

clsID   concatinatedvalue   stdID   c1      c2      c3      c4      

cls1    10-HE-HQ-UA         10      HE      HQ      UA      NULL    
cls1    11-H1-HQ-UA         11      HQ      H1      UA      NULL    

cls2    20-AB-HG            20      HG      AB      NULL    NULL    
cls2    21-H2-HQ-UA         21      H2      HQ      UA      NULL    
cls2    22-HQ-UA            22      NULL    HQ      UA      NULL    

cls3    30-AB-HG            30      HG      AB      NULL    NULL    
cls3    31-GH-HQ-UA         31      HQ      GH      UA      NULL    
cls3    32-HQ-UA            32      NULL    HQ      UA      NULL    
cls3    33                  33      NULL    null    null    NULL    

LEAVE A COMMENT