如何使用 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
该错误可能是由
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