And here is the query adapted to the composite primary key of anlkurse table.
Can you explain more clearly what you mean when you say:
"Your query does not show the result for every ID."

SELECT LETZTER.ANLDETAIL_WKN, LETZTER.DATUM, VORLETZTER.DATUM
FROM TICKER

JOIN (
    SELECT ANLDETAIL_WKN, DATUM
    FROM ANLKURSE
)AS LETZTER
ON LETZTER.ANLDETAIL_WKN = TICKER.ANLDETAIL_WKN

JOIN (
    SELECT ANLDETAIL_WKN, DATUM
    FROM ANLKURSE
)AS VORLETZTER
ON VORLETZTER.ANLDETAIL_WKN = TICKER.ANLDETAIL_WKN
AND CAST(FORMATDATETIME(VORLETZTER.DATUM, 'yyyyMMdd') AS BIGINT) + CAST(VORLETZTER.ANLDETAIL_WKN AS BIGINT) <> CAST(FORMATDATETIME(LETZTER.DATUM, 'yyyyMMdd') AS BIGINT) + CAST(LETZTER.ANLDETAIL_WKN AS BIGINT)

ORDER BY LETZTER.DATUM DESC, VORLETZTER.DATUM DESC
LIMIT 1

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to