早上好 我有一个像下面这样的表,我必须根据“DT1-Increased_Reason”列条目重复这个表。
Region Market Cluster Report_Name DT1-Increased_Reason
abc CT NECTC11123 NECTC11 TMO_Waiting For Report/Recommendations Approval;#ERIC_Delay between Start to Submit. Refer to DT1-Increased CT Reason (Start to Submit);#
def LA GCR_OPT_WELA TMO_Waiting For Report/Recommendations Approval;#
abc NJ NENJC086567 Westchester_02 ERIC_Drive Test Taking too Long;#ERIC_Lack Of GSC Resources/Queuing DT Drives;#ERIC_Cluster Having Too Many RF Issues Needing Tuning;#
您可以观察到“DT1-Increased_Reason”列中的条目有多个使用“#;”
我想要的数据是
Region Market Cluster Report Name DT1-Increased_CT_Reason_Start_to_Accept
abc CT NECTC11123 NECTC11 TMO_Waiting For Report/Recommendations Approval
abc CT NECTC11123 NECTC11 ERIC_Delay between Start to Submit. Refer to DT1-Increased CT Reason (Start to Submit)
def LA GCR_OPT_WELA TMO_Waiting For Report/Recommendations Approval;#
abc NJ NENJC086567 Westchester_02 ERIC_Drive Test Taking too Long
abc NJ NENJC086567 Westchester_02 ERIC_Lack Of GSC Resources/Queuing DT Drives
abc NJ NENJC086567 Westchester_02 ERIC_Cluster Having Too Many RF Issues Needing Tuning;#
答案 0 :(得分:0)
如果您知道最大数量,可以这样做:
select t.Region, t.Market, t.Cluster, t.ReportName,
substring_index(DT1_Increased_CT_Reason_Start_to_Accept, ';#', 1)
from t
union all
select t.Region, t.Market, t.Cluster, t.ReportName,
substring_index(substring_index(DT1_Increased_CT_Reason_Start_to_Accept, ';#', 2), ';#', -1)
from t
where DT1_Increased_CT_Reason_Start_to_Accept like '%;#_%'
union all
select t.Region, t.Market, t.Cluster, t.ReportName,
substring_index(substring_index(DT1_Increased_CT_Reason_Start_to_Accept, ';#', 3), ';#', -1)
from t
where DT1_Increased_CT_Reason_Start_to_Accept like '%;#%;#_%';
您可以为其他每个原因添加另一个子查询。