【发布时间】:2021-06-16 17:49:12
【问题描述】:
我在雅典娜有一张ORC Serde 的桌子。该表包含一个名为greeting_message 的字符串列。它也可以包含 null 值。我想找出表格中有多少行有特定的文本作为模式。
假设我的示例数据如下所示:
|greeting_message |
|-----------------|
|hello world |
|What's up |
| |
|hello Sam |
| |
|hello Ram |
|good morning, hello |
| |
|the above row has null |
| Good morning Sir |
现在对于上表,如果我们看到总共有 10 行。其中 7 个没有 null 值,其中 3 个只有 null/空值。
我想知道有多少行包含特定单词。
例如,考虑单词hello。它存在于 4 行中,因此此类行的百分比为 4/10,即 40 %。
另一个例子:morning 这个词出现在 2 条消息中。因此,此类行的百分比为 2/10,即 20 %。
请注意,我正在考虑 null 也在分母的计数中。
【问题讨论】:
标签: mysql contains amazon-athena presto string-function