[英]Count values between double quotes and brackets
How can I group by and count the values separated by double quotes between the brackets?如何分组并计算括号之间用双引号分隔的值? I have 400K rows, so I'm also concerned about performance.
我有 400K 行,所以我也关心性能。
["853","1800"]
["852","1500"]
["833","1800"]
["857","1820"]
["23468","3184"]
.....
Desired output:所需的 output:
Value Count
23468 1212
09692 987
... ...
Do you mean something like this?你的意思是这样的吗? (The
with
clause is only for testing - remove it, and use your actual table and column names in the main query.) (
with
子句仅用于测试 - 删除它,并在主查询中使用您的实际表名和列名。)
with
sample_data (j_arr) as (
select '["853","1800"]' from dual union all
select '["852","1500"]' from dual union all
select '["833","1800"]' from dual union all
select '["857","1820"]' from dual union all
select '["23468","3184"]' from dual union all
select '["013", "013", "013"]' from dual
)
select str, count(*) as ct
from sample_data cross apply json_table(j_arr, '$[*]' columns str path '$')
group by str
order by ct desc, str -- or whatever you need
;
STR CT
-------- ---
013 3
1800 2
1500 1
1820 1
23468 1
3184 1
833 1
852 1
853 1
857 1
I am sorry, but I have no clue what "register" means in this context.对不起,但我不知道“注册”在这种情况下是什么意思。 If you mean that you have 400K rows, I can't see how performance would be an issue.
如果你的意思是你有 400K 行,我看不出性能会有多大的问题。 A quick test on my system (with 402K rows) took about 0.33 seconds.
对我的系统(有 402K 行)进行快速测试大约需要 0.33 秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.