Re: all the table values equal

From: Michele Petrazzo - Unipex <michele(dot)petrazzo(at)unipex(dot)it>
To: Oliveiros d'Azevedo Cristina <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: all the table values equal
Date: 2010-09-21 08:11:23
Message-ID: 4C9868AB.6050200@unipex.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oliveiros d'Azevedo Cristina ha scritto:
> Hello again, Michele,
>

Ciao,

> I haven't open my mailbox during weekend so I couldn't follow up your
> question.
>

No problem!

> It would help if you explain a little better the background of the
> problem you're trying to solve.
>
> You want to find all the user IDs which have the same value on a
> given time interval?
>
> Is my understanding correct?
>

Yes.

Re-reading my post I saw that I could explain better!

id_user | value | datetime
1 | 1 | xxx
1 | 2 | xxx+1
1 | -1 | xxx+2
2 | -1 | xxx
2 | -1 | xxx+1
3 | 4 | xxx
3 | 10 | xxx+1
3 | 4 | xxx+2
4 | 3 | xxx
4 | 3 | xxx+1

So, the new question: how I can find which id_user has _all_ the "value"
that I'm looking for? Say -1 as 3 and I want a id_user=2 for the first
and for the latter id_user=4

Thanks,
Michele

> Best, Oliver
>
> ----- Original Message ----- From: "Michele Petrazzo - Unipex"
> <michele(dot)petrazzo(at)unipex(dot)it> To: "Oliveiros d'Azevedo Cristina"
> <oliveiros(dot)cristina(at)marktest(dot)pt> Cc: <pgsql-sql(at)postgresql(dot)org> Sent:
> Friday, September 17, 2010 4:45 PM Subject: Re: [SQL] all the table
> values equal
>
>
>> Oliveiros d'Azevedo Cristina ha scritto:
>>> Howdy , Michele,
>>>
>>> Give this a try
>>>
>>> SELECT id_user FROM t_your_table WHERE datetime BETWEEN A --
>>> plug here beginning of interval AND B -- and end here GROUP BY
>>> id_user HAVING COUNT(*) = -SUM(value)
>>>
>>> Then tell me if it gives you what you want
>>
>>
>> Thanks, it works, but... it's really a trickle that exploits the
>> value -1 if I understand how its work. If there is another value
>> where look for? Example 13?
>>
>> Thanks
>>
>> -- Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org) To
>> make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message negora 2010-09-21 08:17:07 Re: all the table values equal
Previous Message Dmitriy Igrishin 2010-09-21 07:19:08 Re: Jagged/ragged arrays