sql - 如何在蜂巢中进行字数统计
问题描述
我有一张table_a
像
query
------
apple
no fruit
this is
not a number
我想编写配置单元查询以根据空间获取字数,例如
query count
------ ------------
apple 1
no fruit 2
this is 2
not a number 3
解决方案
一种方法是拆分为数组并计算元素:
select t.*, size(split(query, ' '))
如果要将多个空格计为单个分隔符:
select t.*, size(split(query, '[ ]+'))
推荐阅读
- kubernetes - 由于活性探测失败,Argo 工作流卡在挂起?
- c# - 从 Xml 中删除元素会在重新加载时破坏格式
- javascript - 返回一个常规数组而不是 Observable
在 RxJS 中 - c++ - 当我使用 size(vec) 而不是 vec.size() 来查找向量的大小时出现错误。如何解决这个问题?
- reactjs - 如何在我的 createContext() 和 createContext().Provider 中管理 2 个不同的状态?
- macos - 在 MacOS 中如何防止 hosts 文件被更改为原始文件?
- swift - 在 Firebase 中为 TextView Swift 保存字体和大小的方法是什么
- algorithm - N 个数字数组的快速排序基本案例
- aem - 在 HTL (Sightly) 中以 JSON 格式访问 AEM 组件数据
- excel - 典型 Excel 365 对象的 Microsoft 文档是指“适用于列表中的对象”,但“适用于列表”在哪里?