Hey, I want to make a query that will give me the same as this in SQL:
select testresult.*,max(timeEnd)
from testresult
group by testres开发者_如何学Goult.idTest
idTest
is not PK in testresult.
it is FK in test
the need is for the maximal testresult
for any test
let's say
s=query()
s[0].id ;is that TestResult
You can group by any field, not only by primary key.
TestResult.objects.values('idTest').annotate(max_time_end=Max('timeEnd')).order_by()
精彩评论