[odb-users] Re: How to perform an aggregate subquery
Boris Kolpackov
boris at codesynthesis.com
Mon Apr 1 04:57:46 EDT 2024
Aldo Laiseca <alaiseca at gmail.com> writes:
> I need to find the most recent T1 (based on field timestamp_action) having a foreign key to T2 matching a particular value of T2.name. In SQL, something like this:
>
> select t1.* from t1
> where t1.timestamp_action = (select max(t1.timestamp_action)
> from t1 join t2 on t1.id_t2 = t2.id
> where t2.name = ?))
>
>
> How could I write such a query using ODB?
By using a view:
https://www.codesynthesis.com/products/odb/doc/manual.xhtml#10
Generally, a lot of "how do I do X in ODB" can be answered by at least
skimming through the documentation once so that you have an idea of the
functionality available.
More information about the odb-users
mailing list