I am starting to understand aggregation and annotation in django, but I am having a hard time translating the following sql

select au.username as 'user name', count(1) as event_count , min(time(log.start_date)) as min_tod, max(time(log.start_date)) as max_tod
      from log as log join auth_user as au on log.user_id=au.user_id
      group by au.username order by event_count desc;

This will give me the number of events per user, and the max and min time of day that this occured (so I can know the working hours of a specific individual). However, I can't figure out how to perform "min(time(log.start_date))" since django.db.models.Min takes a field name, and I want to run datetime.time on the field before performing the min function.
Is there a way to do this without dropping into raw mode?

Carl

--
Carl Zmola
301-562-1900 x315
czm...@woti.com


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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.


Reply via email to