复制代码 代码如下:
CREATE TABLE TMP_PRODUCT
(PRODUCT_TYPE VARCHAR2(255),
PRODUCT_NAME VARCHAR2(255));
复制代码 代码如下:
SELECT PRODUCT_TYPE,
WM_CONCAT(PRODUCT_NAME) || MAX(STR) AS PRODUCT_MULTI_NAME
FROM (SELECT PRODUCT_TYPE,
PRODUCT_NAME,
CASE
WHEN ALL_SUM > 4000 THEN
'...'
ELSE
NULL
END AS STR
FROM (SELECT PRODUCT_TYPE,
PRODUCT_NAME,
SUM(VSIZE(PRODUCT_NAME || ',')) OVER(PARTITION BY PRODUCT_TYPE) AS ALL_SUM,
SUM(VSIZE(PRODUCT_NAME || ',')) OVER(PARTITION BY PRODUCT_TYPE ORDER BY PRODUCT_NAME) AS UP_SUM
FROM TMP_PRODUCT)
WHERE (UP_SUM <= 3998 AND ALL_SUM > 4000)
OR ALL_SUM <= 4001)
GROUP BY PRODUCT_TYPE
新闻热点
疑难解答