Spring 如何使用connect by将逗号分隔的值拆分为列
我有一个小于的列,您可以按如下方式使用multiset和hierarchy查询:Spring 如何使用connect by将逗号分隔的值拆分为列,spring,oracle,spring-boot,spring-data-jpa,Spring,Oracle,Spring Boot,Spring Data Jpa,我有一个小于的列,您可以按如下方式使用multiset和hierarchy查询: Select user_name, listagg(market_code, ',') within group (order by pos) as market_code, In_use From (Select user_name, regexp_substr(market_code, '[^,]+',1, column_value) as market_cod
Select user_name,
listagg(market_code, ',') within group (order by pos) as market_code,
In_use
From
(Select user_name,
regexp_substr(market_code, '[^,]+',1, column_value) as market_code,
in_use,
column_value as pos
From t,
table(cast(multiset(
select level from dual
connect by level <= length (regexp_replace(t.market_code, '[^,]+')) + 1
) as sys.OdciNumberList)) levels) t
Where market_code in ('EUP','APCAC')
Group by user_name, in_use
Having count(distinct market_code) = 2
上面的查询显示了count=2的用法,由于我们使用了count=2,您可以在for或和查询中使用count=1和相应的市场代码谢谢。理解你的答案花了一些时间。这就解决了问题。