I have phpmyadmin to test it but I didn`t manage to get the generated sql 
using underline.

with or without distinct argument it gives 

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
    exec ccode in environment
  File "C:/web2py/applications/OPM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/OPM/controllers/default.py>, line 
610, in <module>
  File "C:\web2py\gluon\globals.py", line 172, in <lambda>
    self._caller = lambda f: f()
  File "C:\web2py\gluon\tools.py", line 2533, in f
    return action(*a, **b)
  File "C:\web2py\gluon\tools.py", line 2533, in f
    return action(*a, **b)
  File "C:/web2py/applications/OPM/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/OPM/controllers/default.py>, line 
529, in timeline_opm
    print 
db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
AttributeError: 'Field' object has no attribute '_count'


Em sexta-feira, 9 de março de 2012 09h13min01s UTC-3, Niphlod escreveu:
>
> ok, can you print here what is the result of :
>
> db.contadores.id_impressora._count(distinct=db.contadores.id_impressora)
>
> (mind the _ before count.)
>
> If you can fire off queries on your db using another tool than web2py 
> (let's say, phpmyadmin), try to copy the resulting string into that and 
> watch if the query raises an error.
>
> Il giorno venerdì 9 marzo 2012 13:02:49 UTC+1, Fabiano Faver ha scritto:
>>
>> MySQL
>>
>> Em sexta-feira, 9 de março de 2012 08h59min46s UTC-3, Niphlod escreveu:
>>>
>>> what db are you using ?
>>>
>>>
>>> Il giorno giovedì 8 marzo 2012 15:20:17 UTC+1, Fabiano Faver ha scritto:
>>>>
>>>> I`m trying to select distinct printers used in each day but i`m not 
>>>> managing to use the distinct argument
>>>>
>>>> count = db.contadores.id_impressora.count()
>>>> for row in db((db.contadores.id
>>>> >0)&(db.contadores.data<=today)).select(db.contadores.data,count,groupby=db.contadores.data):
>>>>         print row.contadores.data, row[count]
>>>>
>>>> if I use something like
>>>>     
>>>>   db.contadores.id_impressora.count(distinct=db.contadores.id_impressora)
>>>>
>>>> it gives:
>>>>
>>>> Traceback (most recent call last):
>>>>   File "C:\web2py\gluon\restricted.py", line 204, in restricted
>>>>     exec ccode in environment
>>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>>> <http://127.0.0.1:8000/admin/default/edit/OPM/controllers/default.py>, 
>>>> line 581, in <module>
>>>>   File "C:\web2py\gluon\globals.py", line 172, in <lambda>
>>>>     self._caller = lambda f: f()
>>>>   File "C:/web2py/applications/OPM/controllers/default.py" 
>>>> <http://127.0.0.1:8000/admin/default/edit/OPM/controllers/default.py>, 
>>>> line 516, in timeline_opm
>>>>     count = db.contadores.id_impressora.count(distinct=('id_impressora'))
>>>> TypeError: count() got an unexpected keyword argument 'distinct' 
>>>>
>>>>
>>>> How can I use distinct count here?
>>>>
>>>

Reply via email to