On Tue, 2006-10-03 at 18:21 +0400, Grigory Fateyev wrote:
> Hello James Bennett!
> On Tue, 3 Oct 2006 08:28:02 -0500 you wrote:
>
> >
> > On 10/3/06, Grigory Fateyev <[EMAIL PROTECTED]> wrote:
> > > I have a list of ip in table, but this ip repeats many times. I
> > > need to show each ip only once with some statistic. How to do this?
> >
> > http://www.djangoproject.com/documentation/db_api/#distinct
>
> I don't get it, Blog.objects.all().distinct() is't working like sql
> query: select distinct column from blog;?
In both SQL and Django, "distinct" means "select distinct rows". So if
you run Blog.objects.all().distinct(), you will have every row returned,
since each row has a distinct value in the primary key column and thus
is not identical to any other row.
Something like Blog.objects.values('ip').distinct() will extract all the
distinct values from the "ip" column, however, as Rajesh points out,
elsewhere, if you also want to collect other statistics, you are going
to need to use custom SQL.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users
-~----------~----~----~----~------~----~------~--~---