简体   繁体   English

AWS Athena 中的 MYSQL

[英]MYSQL in AWS Athena

Using AWS Athena (so querying with MySql) I'm trying to retrieve information how many times the same IP has been logged.使用 AWS Athena(因此使用 MySql 进行查询)我正在尝试检索相同 IP 已记录多少次的信息。 I have columns: timestamp, IP, country.我有列:时间戳,IP,国家。 I would like to count unique occurrences of each IP.我想计算每个 IP 的唯一出现次数。

I'm trying with this query but results are wrong:我正在尝试使用此查询,但结果错误:

SELECT timestamp as Timestamp,
       count(httprequest.clientIp) as Count,
       httprequest.country as Country
FROM table_name
GROUP BY timestamp, httprequest.country

Thank you for helping achieving me this counter query.感谢您帮助我完成了这个计数器查询。

EDIT:编辑:

Sample data:样本数据:

{
    "timestamp":1610808650667,"httpRequest": 
               {"clientIp":"11.111.111.111",
                "country":"UK"}
}

If you only want to know how many times a certain IP has been logged, the IP should be the only column in your group by clause:如果您只想知道某个 IP 已记录多少次,则 IP 应该是您的group by子句中的唯一列:

SELECT   httprequest.clientIp, COUNT(*)
FROM     table_name
GROUP BY httprequest.clientIp

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

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