简体   繁体   中英

AWS Athena CAST with GROUP BY

I have a table in Athena AWS with a timestamp field. I want to group them by date. My SQL query is:

SELECT CAST(createdat AS DATE) FROM conversations GROUP BY createdat But my result is the following: 阿斯达

As you can see the group by does not work, and the reason is that the new table has the name field _col0 instead createdat . I also tried: SELECT CAST(createdat AS DATE) FROM conversations GROUP BY _col0 but I got and error.

Does anybody has any suggestions? I will appreciate it

Try using then same in group by

SELECT CAST(createdat AS DATE) 
FROM conversations 
GROUP BY CAST(createdat AS DATE)

Same but a little shorter

SELECT CAST(createdat AS DATE) 
FROM conversations 
GROUP BY 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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