我如何在 Hive 中做到这一点?
columnA columnB columnC
100.10 50.60 30
100.10 50.60 30
100.10 50.60 20
100.10 70.80 40
输出应该是:
columnA columnB No_of_distinct_colC
100.10 50.60 2
100.10 70.80 1
我认为正确的查询:
SELECT columnA,columnB,COUNT(distinct column C)
from table_name
group by columnA,columnB
这样对吗? SQL也很好。
更新:如何找到 columnC 的标准偏差?尽快需要这个。
最佳答案
是的,这几乎是正确的。但是你有一个简单的错误。您的列名在 COUNT 中是错误的。
SELECT columnA,columnB,COUNT(DISTINCT columnC) No_of_distinct_colC
from table_name
group by columnA,columnB
关于SQL/Hive 计数不同的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18091965/