如何使用hive查询找到最常见的颜色?

时间:2016-03-31 16:45:36

标签: hadoop hive

我有一张下表

<!DOCTYPE html>
<html>
    <body>
        <h1 class="class">Hello Plunker!</h1>
      
        <div> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed iaculis, 
      erat quis eleifend accumsan, justo nisl porttitor ante, a pretium ex enim id 
      mauris. Suspendisse non vehicula nibh. Phasellus vitae consectetur est, id 
      condimentum metus. Etiam placerat hendrerit erat et interdum. Nulla convall
      is rhoncus volutpat. Aliquam iaculis, velit id iaculis semper, diam nulla 
      hendrerit sem, vitae pellentesque elit felis eu eros. Praesent id viverra tortor. 
      Donec vel rhoncus arcu. Donec ut fringilla mi. Nulla vestibulum viverra odio 
      vel ullamcorper. In vulputate nunc mattis tellus vehicula, sit amet commodo
      metus ornare. Quisque pretium ligula dolor, et lacinia ligula lacinia in.
      Aenean vitae ex quis erat tincidunt elementum a ac sem. Nulla vel placerat neque. 
      Nam vitae euismod quam.
  
      Donec vitae nibh nibh. In hac habitasse platea dictumst. Cras eget dolor porta,
      fringilla magna in, congue augue. Suspendisse scelerisque diam at ligula 
      vulputate egestas. Sed vitae metus neque. Praesent sed lacus blandit, 
      hendrerit libero non, maximus metus. Phasellus interdum erat dictum, rhoncus
      lectus in, tincidunt leo. Quisque bibendum pellentesque ipsum et elementum.
  
      Vivamus dictum condimentum lacus non vulputate. Etiam pulvinar eu magna id
      lacinia. Phasellus efficitur placerat ante, in faucibus mauris elementum ut. 
      Nam dui quam, euismod ac sem at, feugiat porttitor ex. Donec id felis est.
      Aenean euismod nibh ut sem interdum, et ullamcorper lorem condimentum. 
      Pellentesque dictum commodo blandit. Curabitur eu felis sed dui vulputate 
      ullamcorper non nec odio. Nulla urna purus, hendrerit non malesuada in,
      consequat quis nunc. Mauris finibus turpis in turpis egestas, vitae ornare 
      ante tempus. Suspendisse eu dapibus mi, id aliquam arcu. Aliquam gravida 
      rutrum ullamcorper. Proin ultrices lectus eu velit imperdiet, vitae aliquam 
      ante venenatis. Maecenas ullamcorper quis urna sit amet efficitur. 
      Proin consectetur vehicula elit eget tincidunt.
  
      Aenean accumsan tempus tellus feugiat cursus. Praesent pulvinar finibus ligula,
      nec ornare lorem posuere id. Duis condimentum tempor scelerisque. Nullam ante 
      sem, maximus ac malesuada a, eleifend id felis. Phasellus gravida dui et nibh 
      laoreet bibendum. Aliquam vulputate nulla in nisl accumsan porta. Praesent feugiat, 
      diam et faucibus porta, odio orci egestas lorem, ac posuere nunc mauris id ipsum. 
      Curabitur porta tempor felis, ut pellentesque arcu dictum et. Nunc quis felis 
      risus. Praesent sed fermentum nisi, ut bibendum felis. Integer velit sapien,
      hendrerit ac erat quis, porta tempus sapien. Integer mattis posuere dolor 
      vitae luctus. Cras commodo elementum ligula at imperdiet. Nullam efficitur 
      metus eget volutpat aliquet.
  
      Morbi ac erat a sem convallis convallis at non magna. Cras nec lectus consequat 
      est auctor vestibulum et non metus. Sed luctus lacinia elit, ut ultricies ante 
      venenatis vitae. Ut pellentesque est eget placerat tincidunt. Pellentesque molestie 
      id ligula fringilla pellentesque. Praesent viverra ipsum in mi facilisis dapibus. 
      Interdum et malesuada fames ac ante ipsum primis in faucibus. Vivamus efficitur 
      augue in lectus rhoncus, eu faucibus ex ornare. Aliquam sodales tincidunt ante, 
      nec cursus velit rutrum et. Donec sagittis ullamcorper tortor eget interdum.
      Aliquam efficitur, metus in feugiat condimentum, ligula orci tristique eros, 
      ut rhoncus sapien risus vitae leo.
      </div>
        <a class="video" href="#">
            <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAn0AAAF8CAYAAAC6xw31AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAALlBJREFUeNrs3QtcVVXe/3HFVEREUFAuchEUMbwEXkHtwTuoyXjJv2aak1Oal2mcJh2nR81MG22q4SHNmqYprXTSMDEVvKT/vw14ybskKSCCXBQFRETUwv/+lfTo8YAH9j6Hc/m8X6/9srbstc9eewtf1lp7rfr1D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AAAAQ+gAAAEDoAwAAgMGh70eqAQAAwKr9JKHvJvUAAABg1col9F2hHgAAAKzaFQl9+dQDAACAVcuX0HeWegAAALBqZyX0ZSjbdeoCAADAKknOy5DQ95OyHaQ+AAAArJLkvJ8q5+nbr2yl1AkAAIBVKb2b836dnFmmbdlGvQAAAFiV7XdzXr0G9+wsULYmytaG+gEAALB4B5QtqfJ/Guj8pbzU4XZ3AwAAgGX6Xtm2KNudqkKf/MXper+0+HlRXwAAABZHXtyIV7aKe3c20POFEvxk7r5LyuajbI2pOwAAALN37W7YS6p3TwtfpfoPOdhe2XopW09la0pdAgAAmB2Zh09a92QMX3lVX1TfwMKkRTDg7uapbC71fukCbkA9AwAAmIzMr3xD2YqULVfZ0u9uPz3swP8vwACQCQiSKQXIJgAAAABJRU5ErkJggg==" alt="">
        </a>
      
        <script data-require="jquery@2.2.0" data-semver="2.2.0" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
        <script src="script.js"></script>
    </body>

</html>

现在,我需要找到哪种颜色最常见? 我使用以下查询获得了所有颜色的计数。

name  red  black  white
US      1    1      1
UK      0    1      0
EU      1    1      0
AUS     0    0      0

这将给出以下输出:

select colorName,count(name) as total
from
(select
case
when red == 1 then 'red'
when black == 1 then 'black'
end as colorName, name from countrytable)a
group by colorName;

但我希望获得最常见的价值,即&#34; black&#34;。我怎么能在Hive中这样做?

red black white
2   3     1 

1 个答案:

答案 0 :(得分:0)

添加另一个步骤,按计数的降序排序/排序,并将其限制在前1条记录。

select colorName,count(name) as total
from
    (select
       case
           when red == 1 then 'red' 
           when black == 1 then 'black'
       end as colorName, name from countrytable)a
group by colorName
ORDER BY count(name) DESC 
LIMIT 1;