2017-05-30 80 views
-1

我想構建一個蜂巢式查詢,只有下面的功能或這些功能的組合。例如,所述特徵包括蜂巢查詢除了條件

名稱=「摘要」

名稱=「細節」

NAME1 =「車輛統計」

基本上,該查詢應排除在名字中的所有其他特徵和name1。

我對配置單元相當陌生。在SQL中,我知道這可以使用除了關鍵字。只是想知道是否有一些功能可以實現相同。

非常感謝!

+2

你可以發佈一些樣本數據和預期的輸出爲格式文本?目前還不清楚你需要什麼。 –

+0

就像這樣:用'where 1 = 2'創建查詢,並用'OR'連接你的條件。 – leftjoin

+0

[某些特定排除條件的Hive查詢可能重複](https://stackoverflow.com/questions/44286001/hive-query-with-certain-specific-exclude-conditions) –

回答

-1

如果我理解正確的話,我處理這個使用group byhaving

select ? 
from t 
group by ? 
having sum(case when name = 'summary' then 1 else 0 end) > 0 and 
     sum(case when name = 'details' then 1 else 0 end) > 0 and 
     sum(case when name1 = 'vehicle_stats' then 1 else 0 end) > 0; 

?是你想要的總結列。