简体   繁体   English

如何在蜂巢中输出多个分组

[英]How to output multiple group by output in hive

I need to do multiple count and do a group by , I am trying this in hive but its error out, any body good with hiveQL can help here , how to do same in either hive/pig 我需要进行多次计数并进行分组,我正在蜂巢中尝试此操作,但它的错误已经解决了,任何对hiveQL有益的身体都可以在这里提供帮助,如何在蜂巢/猪中做到这一点

Logic for 1st count 第一计数逻辑

Select col1,clo2 ,col3 , count (distinct col4, col5) from table1 where col6 = 1 group by col1,clo2 ,col3

Logic for 2nd count 第二计数逻辑

Select col1,clo2 ,col3 , count (distinct col4, col5) from table1 where col7 = 1 group by col1,clo2 ,col3

Final OP expected as below : 最终OP预计如下:

col1,clo2 ,col3 ,count1 ,count2 

@Navneet, Why would you like to find out count (distinct col4, col5) ? @Navneet,您为什么要找出count (distinct col4, col5) As this will always give you output 1 . 因为这将始终为您提供输出1 So your count1 and count2 will be always 1 . 因此,您的count1 and count2 will be always 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM