Skip to content
Advertisement

Query working in mySql and not working in Oracle

Below is the query which is working in MySQL and not working in Oracle. Here I need to get the latest Date and corresponding event from table r for every ID in Table a . ID is unique.



Output should be like this —————————

Advertisement

Answer

Your select is:

Your group by is:

These are incompatible — what are the values of all the other columns in the select apart from a.id. That MySQL supports this is a (mis)feature of the database, not supported by almost any other database.

The most typical solution is to fix these so they are compatible:

Your group by is:

In your case, the group by is probably not needed at all:

You only need it if there are multiple rows with the same max date.

The most common solution in Oracle fixes this problem:

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