db(...).select(orderby=~db.table.field.max()) should translate in "... ORDER BY MAX(table.field) DESC ...". Are you saying it does not or are you mixing ~ with raw sql?
On Jan 22, 8:01 am, notabene <[email protected]> wrote: > DESC: ORDER BY ~MAX(arrstart) result in a strange sorting! > ASC: ORDER BY MAX(arrstart) works as expected: > I can insert DESC in raw sql, but howto specify in db.select? > > SELECT arrdato.arrid, MAX(arrstart), COUNT(arrid) FROM arrdato WHERE > ((arrdato.stedid=1 OR arrdato.arrangid=1) AND > arrdato.arrstart<'2009-01-22 14:16:48') GROUP BY arrdato.arrid ORDER > BY ~MAX(arrstart) LIMIT 10 OFFSET 0; > > Result > [(3, u'2009-01-20 14:53:46', 1), (4, u'2009-01-14 16:56:11', 1), (5, > u'2009-01-11 16:58:00', 1), (12, u'2009-01-20 13:08:00', 1), (15, > u'2009-01-22 13:16:00', 1), (16, u'2009-01-20 13:34:00', 1), (1, > u'2008-12-31 15:08:41', 1)] > > 3 2009-01-20 14:53:46 > 4 2009-01-14 16:56:11 > 5 2009-01-11 16:58:00 > 12 2009-01-20 13:08:00 > 15 2009-01-22 13:16:00 > 16 2009-01-20 13:34:00 > 1 2008-12-31 15:08:41 > > SELECT arrdato.arrid, MAX(arrstart), COUNT(arrid) FROM arrdato WHERE > ((arrdato.stedid=1 OR arrdato.arrangid=1) AND > arrdato.arrstart<'2009-01-22 14:46:06') GROUP BY arrdato.arrid ORDER > BY MAX(arrstart) LIMIT 10 OFFSET 0; > > Result > [(1, u'2008-12-31 15:08:41', 1), (5, u'2009-01-11 16:58:00', 1), (4, > u'2009-01-14 16:56:11', 1), (12, u'2009-01-20 13:08:00', 1), (16, > u'2009-01-20 13:34:00', 1), (3, u'2009-01-20 14:53:46', 1), (15, > u'2009-01-22 13:16:00', 1)] > > 1 2008-12-31 15:08:41 > 5 2009-01-11 16:58:00 > 4 2009-01-14 16:56:11 > 12 2009-01-20 13:08:00 > 16 2009-01-20 13:34:00 > 3 2009-01-20 14:53:46 > 15 2009-01-22 13:16:00 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

