>> I'm not sure why you're GROUPing BY "note" as you don't have any 
>> aggregate functions in play in your example code.
> 
> I need grouping, because in the table could be several rows with the 
> same note and I want only "unique" note results.


Then using distinct() might do the trick:

   entries = entries.distinct()

Or, if you stick with using raw SQL, it's likely better to do

   SELECT DISTINCT note
   FROM journals_journal
   WHERE length(note) > 0 and note like 'whatever%'
   ORDER BY note

as this tells the DB exactly what your intentions are, and it can 
optimize accordingly.

Unfortunately, for all these cases, Length() is a 
non-standard/non-portable function and is sometimes len() but 
othertimes length() depending on your back-end.  Sigh. :(

If one needed to workaround that and could assume that you had 
some sort of alpha-numeric data in the field, it could be reduced 
to a single test of

   WHERE note ILIKE '%[a-z0-9]%'

or

   ...filter(note__icontains='[a-z0-9]')

Just a few more ideas,

-tim




--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to