Try the following:

edit gluon/sql.py and replace

        if attributes.get('distinct', False):
            sql_s += ' DISTINCT'

with

        if attributes.get('distinct', False)==True:
            sql_s += ' DISTINCT'
        ekif attributes.get('distinct', False):
            sql_s += ' DISTINCT ON %s' % attributes['distinct']

then in your query use

    db(...).select(...,distinct=db.table.field1|db.table.field2)

Does it do what you need?


On Jun 2, 2:10 am, Horst Herb <[email protected]> wrote:
> On Tue, Jun 2, 2009 at 4:48 PM, SergeyPo <[email protected]> wrote:
>
> > This works for sure in sqlite, mysql and oracle:
>
> > db().select(db.tablename.fieldname, distinct=True)
>
> > and this is correct approach because I can not imagine biz logic when
> > you want to select distinct values AND their ID's etc. fields. You
> > normally use select distinct when you need a list of available values
> > in a field.
>
> practical example from my own web app:
> A doctor prescribes medication. He can select it from a pharmaceutical 
> database.
> He can select the drug by generic or brand name.
> Each drug comes in a variety of forms, strengths, packet sizes etc.
> plus some incur health system subsidies, some barnd price premiums
> etc.
>
> In most instances, I am not interested whatsoever in 20 manufacturers
> producing the same product and it coming in a variety of packet sizes
> - all I want is Amoxycilin trihydrate tablets 500mg (and not a hundred
> variations thereof cluttering my selection widget). There are some
> 60,000 drug product entries in the larger drug database - and less
> than 2000 unique drugs
>
> But, in order to call up product information and to check allergies
> and interactions - I need the id of the drug.
>
> Just one of a great many practical examples.
>
> Horst
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to