![](/img/trans.png)
[英]Query to count all records without certain key in the json column of the snowflake table
[英]Count JSON column in Snowflake
Json 数据开始如下:
{"prizes":
[ {"year":"2018",
"category":"physics",
"laureates":[ {"id":"960","firstname":"Arthur","surname":"Ashkin"}
, { "id":"961","firstname":"G\u00e9rard","surname":"Mourou" }
]
},
...
]
}
首先将数据展平到我需要的最低级别(获奖者),然后应用到“年份”元素,它比获奖者元素高一级。 如果需要,您还可以过滤最低级别的列。
select
count(*)
from NobelPrizeJson
, lateral flatten(INPUT=>json:prizes) prizes
, lateral flatten(INPUT=>prizes.value:laureates) laureates
where prizes.value:year::int > 2010;
这发布在: https : //community.snowflake.com/s/question/0D50Z00008xAQSY/i-have-a-query-that-counts-the-number-of-objects-inside-a-large-json-document -and-now-i-need-to-filter-on-only-objects-with-a-specific-keyvalue-pair-inside-那些-objects-how-can-i-filter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.