Skip to content
Advertisement

AWS Athena: Unsupported correlated subquery type but it works on Mysql and other flavors

For each order in orders table, I’m trying to return the latest order update value based on time_sent, grouped into a single row.

The above select query works fine in MySql but not in AWS Athena.

Working MySQL example below:

https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=66f17cf9f3c8f19f758c7cb1381d8207

Is there a way to accomplish the above using joins?

Advertisement

Answer

It’s possible to achieve this with Window Functions – as available in Athena/Presto 0.172, here an example for getting column a and b, extensible for c and d:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement