Hello, I don't know if it is suitable to post such a question right here. Anyway, I have a simple model as below:
def acct_data(models.Model): timestamp = models.DateTimeField(); msg_type = models.IntegerField(); username = models.CharField(); session_id = models.CharField(); Now I would like to perform a query like this: SELECT * FROM [acct_data] INNER JOIN ( SELECT [session_id], MAX([timestamp]) AS last_time FROM [acct_data] GROUP BY [session_id] ) tmp_tbl ON [acct_data].[session_id] = tmp_tbl.[session_id] and [acct_data].[timestamp] = tmp_tbl.last_time WHERE [msg_type] != 2 I want to accomplish this task by using Django data models. Is that possible? I've been digging Django documentation but unable to find a similar case. If you have ever run into this, please share with me your experience. I'm very thankful for that. Please ask me to clarify if the issue is not stated clearly enough. I'm still a newbie. Thanks, Thai. -- 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.