Hadoop Hive查询-SQL

发布于 2025-02-10 02:54:03 字数 234 浏览 2 评论 0原文

我在 hive 中写了一个查询。它不起作用 查询:

hive>> select country ,max(total_count) from (select country, count(airlineid) from airport group by country) t2;

它显示了'country'的表达式

I write a query in hive. it not working
query:

hive>> select country ,max(total_count) from (select country, count(airlineid) from airport group by country) t2;

it shows expression group by 'country' is missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻的心爱 2025-02-17 02:54:03

多个问题。如果格式化它,则应该可以看到它。

select
  country, -- you need to add this in group by after t2.
  max(total_count) -- you need to create/alias a column called total_count
from
  (
    select
      country,
      count(airlineid)
    from
      airport
    group by
      country
  ) t2;

固定SQL-

select
  country,  
  max(total_count) max_total_count
from
  (
    select
      country,
      count(airlineid)total_count
    from
      airport
    group by
      country
  ) t2
group by country
;

Multiple problems. if you format it you should be able to see it.

select
  country, -- you need to add this in group by after t2.
  max(total_count) -- you need to create/alias a column called total_count
from
  (
    select
      country,
      count(airlineid)
    from
      airport
    group by
      country
  ) t2;

Fixed SQL -

select
  country,  
  max(total_count) max_total_count
from
  (
    select
      country,
      count(airlineid)total_count
    from
      airport
    group by
      country
  ) t2
group by country
;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文