簡體   English   中英

上一欄的Concat

[英]Concat from a previous column

我有辦法從邏輯確定的前一列中合並一列嗎?

    
    select
    if(p.mfg is not null , p.mfg, 'Private') as MFG,
    concat(MFG, " ",p.sku) as TITLE
    from product p

您可以使用CASE語句,例如

select
if(p.mfg is not null , p.mfg, 'Private') as MFG,
concat(case when p.mfg is not null then p.mfg else 'Private' end, " ",p.sku) as TITLE
from product p

(OR)使用inline view

select MFG, concat(MFG, " ", sku) as TITLE
from (select if(p.mfg is not null , p.mfg, 'Private') as MFG, sku from product p
    ) tab

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM