14.9.2011 12:46, Jonas H. kirjoitti:
On 09/14/2011 11:37 AM, Иван Иванов wrote:
The problem here is, like Peter said, that you cannot order before
grouping. And that's very annoying.
Of course you can, using a subselect just like I showed. SQLite example:
> .schema
CREATE TABLE a (name varchar, mod int);
e> select * from a;
b1|1
b1|2
b1|3
> select * from a group by name;
b1|3
> select * from (select * from a order by mod desc) group by name;
b1|1
Problem is that is not standard SQL.
In standard implemetation group by _requires_ aggregation function that
is applied to groups so you won't be able to get "last" that way.
It might work non-standard way in some implementations. And thus Django
usually follows standard or smallest common nominator for db backends
such a thing is not possible to support.
--
Jani Tiainen
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.