You could calculate a running total of the string length (using the SUM(...) OVER (...) analytic function) and then use this to truncate the string to 4000 characters:SELECT LISTAGG( CASE WHEN prev_len >= 4000 THEN NULL WHEN prev_len + len <= 4000 THEN value ELSE SUBSTR( value, 1, 4000 - prev_len ) END ) WITHIN GROUP ( ORDER BY line ) AS valueFROM ( SELECT impression, line, LENGTH( impression ) AS len, COALESCE( SUM( 1 + LENGTH( impression ) ) OVER ( ORDER BY line ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ), 0 ) AS prev_len FROM order_impression); 这篇关于限制Oracle SQL查询中返回的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-07 18:04