Bingo!
having =(count1 % 2* *==* *1)

2013/9/5 António Ramos <[email protected]>

> Going with SQLTABLE i have my rows queried like
>
> count1=db.card_logs.id.count()
>
> (db.........)select(db.trabalhador.nome,db.trabalhador.area,count1,groupby=db.trabalhador.nome,
> *having =(count1 % 2 = 1)*)
>
>
> the *having* clause is not accepted , how to do it to query only odd
> counts?
>
>
> I use sqlite!
>
>
>
>
> 2013/9/4 Richard Vézina <[email protected]>
>
>> Ok, so you need to check against actual time which person are still in...
>>
>> If you really just want the persons/users that are still in a give time,
>> I think you need a group by over user_id... So you could set a limit of 2
>> records per user and if you have only one and it is a 'check in' stat value
>> you know this user is still in...
>>
>> Though, SQLFORM.grid() doesn't support aggregation (
>> https://groups.google.com/forum/#!topic/web2py-developers/0pEmptLdND8) since
>> you pass it a query...
>>
>> So, maybe you should think of using the old SQLTABLE or build a custom
>> table yourself with TABLE() and other helpers provide by web2py...
>>
>> First you should try to wrote the SQL query to make sure you can solve
>> this with a single query, if you can, you may use SQLTABLE if you can't and
>> have to iter over record your only remaning option will be a custom table I
>> guess...
>>
>> I can help with the SQL if you need help, but I would need a dumy table
>> with a data sample...
>>
>> :)
>>
>> Richard
>>
>>
>>
>>
>>
>>
>> On Wed, Sep 4, 2013 at 1:17 PM, António Ramos <[email protected]>wrote:
>>
>>> If the user checks his rfid tag within 5 minutes of the last check the
>>> log does not record "check in" or "check out" but "error"
>>>
>>>
>>> 2013/9/4 António Ramos <[email protected]>
>>>
>>>> yes , stat is a string with "chech in" or "check out" i also have a
>>>> timestamp for the check in or check out.
>>>>
>>>> I dont want odd /even hours
>>>>
>>>> I want to know if the user is checked in
>>>>
>>>> I have an RFID app to check in /out outside workers via an rfid tag.
>>>>
>>>> when the user checks firstime, the app records "check in" , after that
>>>> , checking again his rfid tag the app  logs "check out" .
>>>>
>>>> During the day the worker can go out to lunch and checks out, after
>>>> lunck checks in again.
>>>>
>>>>
>>>> so for a user i can have
>>>>
>>>> user a check in   (time...)
>>>> user a check out (time...)
>>>> user a check in (time...)
>>>>
>>>>
>>>> I want to create a grid to show who is inside, so i need a query of
>>>>  odd rfid checks for each user
>>>>
>>>>
>>>>
>>>> 2013/9/4 Richard Vézina <[email protected]>
>>>>
>>>>> Don't understand what you need exactly... Is stat a string type
>>>>> containing 'check in' or 'check out' and you want just odd number of 
>>>>> record
>>>>> or you have an other field with timestamp or something and you want only
>>>>> the odd hours to appear in the grid??
>>>>>
>>>>> Richard
>>>>>
>>>>>
>>>>> On Wed, Sep 4, 2013 at 12:54 PM, António Ramos 
>>>>> <[email protected]>wrote:
>>>>>
>>>>>>
>>>>>> hello i  need to use  the sqlform.grid(query,etc...   to show records
>>>>>>
>>>>>> *my problem*
>>>>>> the query is not just like
>>>>>> ((db.tab1.stat='check in')|(db.tab1.stat='check out'))
>>>>>>
>>>>>>
>>>>>>
>>>>>> i need to query only records that appear with stat='check in' or
>>>>>> 'check out' odd times in tab1 and not even times
>>>>>>
>>>>>>
>>>>>> For example , this should not be in the grid
>>>>>>
>>>>>> user a check in
>>>>>> user a check out
>>>>>> user a check in
>>>>>> user a check out
>>>>>>
>>>>>>
>>>>>> but this should
>>>>>>
>>>>>> user a check in
>>>>>> user a check out
>>>>>> user a check in
>>>>>>
>>>>>>
>>>>>> how do i create a query for this? to use in sqlform.grid(query, ....
>>>>>>
>>>>>>  --
>>>>>>
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "web2py-users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to