David Bicking-2 wrote:
> 
> As written, you were selecting any record with the correct date
> regardless of Ensemble or Steuck.
> 
> David
> 


The following seem to work:

SELECT * FROM tblZO_Haupt AS hpt
WHERE
hpt.zo_tblEnsemble = ....
AND hpt.zo_tblStueck = ...
AND hpt.datum = (
SELECT MAX(hpt_sub.datum)
FROM tblZO_Haupt AS hpt_sub
WHERE hpt_sub.zo_tblSaenger = hpt.zo_tblSaenger
AND hpt_sub.zo_tblEnsemble = hpt.zo_tblEnsemble
AND hpt_sub.zo_tblStueck = hpt.zo_tblStueck
AND hpt_sub.datum <= '2009-08-03 00:00:00'); 

But I didn't really get the deeper meaning of the three conditions in the
subquery: hpt_sub.xyz = hpt.xyz?

Leo


-- 
View this message in context: 
http://www.nabble.com/Problems-with-max%28datestamp%29-in-subquery-tp24905950p25015087.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to