Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 获取配置单元中每个单词的唯一字数_Sql_Hadoop_Hive - Fatal编程技术网

Sql 获取配置单元中每个单词的唯一字数

Sql 获取配置单元中每个单词的唯一字数,sql,hadoop,hive,Sql,Hadoop,Hive,我有一张如下的桌子 从tablename中选择* ID sentence 1 This is a sentence 2 This might be a test 3 America 4 This this 我想写一个查询,将句子拆分成单词,并按降序计算单词数。我想要一个输出,比如 word count Unique

我有一张如下的桌子

从tablename中选择*

ID                   sentence
1              This is a sentence
2              This might be a test
3                     America
4                    This this 
我想写一个查询,将句子拆分成单词,并按降序计算单词数。我想要一个输出,比如

word     count    Unique(ids)

This       4          3
a          2          2
might      1          1
.
.
.
其中count是该单词在列中出现的次数,Unique(ids)是使用该单词的用户数

我在想,我们可以用什么方式编写查询来实现这一点

有人能帮我在蜂箱里做这个吗

谢谢

侧视图

结果将是:

1 This
1 is 
1 a
1 sentense
2 This
2 might
2 be
2 a
2 test
3 america
聚合结果

侧视图

结果将是:

1 This
1 is 
1 a
1 sentense
2 This
2 might
2 be
2 a
2 test
3 america

聚合结果

我删除了不适当的数据库标记。我删除了不适当的数据库标记。