SELECT table1.*,table2.*, table3.*
FROM table1, table2, table3
inner join
(
select table1.id AS pid, max(table1.createtime) AS timestamp
from table1 group by table1.id
) A on A.pid = table1.id AND A.timestamp = table1.createtime
WHERE table3.id = table1.id
ORDER BY table1.createtime;
I am trying to fetch only the last modified record for each id in table1.
For the above query I am getting error as:
"%s:invalid identifier" for "A.timestamp = table1.IDA2A2" this part.
Please let me know what is wrong with this query.
DB is Oracle.
Well part of your problem is you are mixing
JOINsyntax – your query is using both comma joins and ANSI JOIN syntax. You need to properly join the tables: