T SQL Conditional String Concatenation

后端 未结 5 817
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 16:55

Have a 5 columns of address data. I need to concatenate these fields into a single address with spaces in between the values if they exist. If the column has a null value

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-05 17:18

    Something along the lines of:

    select coalesce(street_number+' ','')+
           coalesce(case when street_ext=50 then '1/2' else null end+' ','')+
           coalesce(street_direct+' ','')+
           coalesce(site_street+' ','')+
           coalesce(site_address,'')
    from parcel
    

提交回复
热议问题