Teradata 奇淫技巧
INSERT INTO stgICBatchUpload SELECT MAX(CASE WHEN attr_no = 1 THEN CAST(token AS VARCHAR(20)) END) AS EffectiveDtae, MAX(CASE WHEN attr_no = 2 THEN CAST(token AS VARCHAR(20)) END) AS RIC, MAX(CASE WHEN attr_no = 3 THEN CAST(token AS VARCHAR(5)) END) AS ClassificationType, MAX(CASE WHEN attr_no = 4 THEN CAST(token AS VARCHAR(20)) END) AS SubsectorCode, CURRENT_TIMESTAMP,USER,CURRENT_TIMESTAMP,USER FROM ( SELECT tokennum, 4 AS NumCols, CASE WHEN token ='' THEN NULL ELSE token END AS token, (tokennum-1)/NumCols AS recno, tokennum-(recno*NumCols) AS attr_no FROM TABLE ( STRTOK_SPLIT_TO_TABLE(1,'2021-09-06|6878.HK|BUS|601020#2021-09-06|2099.HK|BUS|051010#2021-09-06|3313.HK|BUS|602010#2021-09-06|3623.HK|BUS|503040#','|#') RETURNS (outkey INTEGER, tokennum INTEGER, token VARCHAR(32)CHARACTER SET UNICODE) ) AS d ) AS T GROUP BY recno