[英]Count distinct values within a column
使用后續的UNNEST嘗試SPLIT (在計數期間跳過空值需要NULLIF ):
with mytable as (
select 1 as id, '11' as values union all
select 2, '11,22' union all
select 3, '' union all
select 4, '11,22,22,33' union all
select 5, '44,55,66,77' union all
select 6, '77,88,99'
)
select id,
(select count(distinct NULLIF(v,''))
from unnest(split(values)) as v) as values
from mytable
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.