Hello,

I have this query, but the the "IL.type" is incorrect. It looks like the
first record value is returned instead of last:

session2.query(func.max(IL._Sid),IL.Number,IL.DriverLicenseNumber,IL.Type,IL.ExpDate).filter(IL.Confirmed=='Yes').group_by(IL.Number,IL.DriverLicenseNumber,IL.ExpDate).all()

Which by searching I should do:

select xyz from query (above)?
I could group by on IL.Type but then I would not get the latest record for
that DL#,exp_date,Number.

How would that look in sqlalchemy?
aka something along:

SELECT IL2.Number,IL2.DriverLicenseNumber,IL2.Type,IL2.ExpDate
  FROM IL2
  JOIN 
(session2.query(func.max(IL._Sid),IL.Number,IL.DriverLicenseNumber,IL.Type,IL.ExpDate).filter(IL.Confirmed=='Yes').group_by(IL.Number,IL.DriverLicenseNumber,IL.ExpDate)
      ) AS IL
    ON IL._Sid = IL2=_Sid


http://stackoverflow.com/questions/9657695/getting-wrong-values-for-other-columns-when-i-select-maxupdated-date

Thanks
Lucas

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to