>
> Here is my sql for this case 
>

SELECT DISTINCT erfgoed.id as id,
statussen.statustype_id as statype_id,
statussen.datum as datum,
erfgoed.naam as naam
FROM erfgoedobjecten as erfgoed
JOIN erfgoedobjecten_statussen as erfgoedobjectstatus
ON erfgoed.id = erfgoedobjectstatus.erfgoedobject_id
JOIN statussen
ON statussen.id = 
(
SELECT id
FROM statussen
WHERE statussen.id = erfgoedobjectstatus.status_id
ORDER BY datum DESC
)
WHERE statussen.statustype_id > 50


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/4b07dd75-df93-4896-91ff-95edcdd74453%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to