aws athena 查询以获取大于特定数字的计数

问题描述 投票:0回答:1

如何使用 AWS Athena 查询获得大于特定数字的

count


SELECT
    concat(cast(date as varchar),' ',substr(time,1,5)) as datetime,
    requestip,
    count(*) as count 
FROM "tk_logs"."btb-cf-aug-2023" 
WHERE
        uri like '/topics/%'
    and cast(concat(cast(date as varchar),' ',substr(time,1,5)) as varchar) >= '2023-08-07 00:59' 
    and count >=100
GROUP BY 1,2
ORDER BY 1 asc

我尝试了上述查询,但出现错误

 Column 'count' cannot be resolved or requester is not authorized to access requested resources
amazon-web-services amazon-athena
1个回答
0
投票

该错误可能是由

count >=100
引起的,因为它是完全聚合的。尝试将其移动到像这样的
HAVING

SELECT
    concat(cast(date as varchar),' ',substr(time,1,5)) as datetime,
    requestip,
    count(*) as count 
FROM "tk_logs"."btb-cf-aug-2023" 
WHERE
        uri like '/topics/%'
    and cast(concat(cast(date as varchar),' ',substr(time,1,5)) as varchar) >= '2023-08-07 00:59' 
GROUP BY 1,2
HAVING count(*) >= 100
ORDER BY 1 asc
© www.soinside.com 2019 - 2024. All rights reserved.