Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id DE93E1337B60 for ; Tue, 21 Sep 2010 07:25:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 99818-05 for ; Tue, 21 Sep 2010 10:25:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id 1BDB6133616B for ; Tue, 21 Sep 2010 07:25:47 -0300 (ADT) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id SBPTZ7PP; Tue, 21 Sep 2010 11:25:45 +0100 Message-ID: <5E43A989C2FA4F60B146DAC454BAA21D@marktestcr.marktest.pt> From: "Oliveiros d'Azevedo Cristina" To: "Michele Petrazzo - Unipex" Cc: References: <4C93803A.4080706@unipex.it> <438B32316EF6496D9641819BA16447A2@marktestcr.marktest.pt> <4C938D09.3050105@unipex.it> <81C545E3469E4DF58720C282A469E78A@marktestcr.marktest.pt> <4C9868AB.6050200@unipex.it> Subject: Re: all the table values equal Date: Tue, 21 Sep 2010 11:25:45 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.51 tagged_above=-5 required=5 tests=BAYES_05=-0.5, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/62 X-Sequence-Number: 34593 >> 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 > OK, So, analysing your new question, the time interval is still important? Or no longer? So writting your query in english : "I want all users that don't change "value" and their value is equal to x ?" Or will you need to find all the users that don't change value with just one query? And the query would return something like id_user | value 2 | -1 4| 3 ? Please advice me on this. I am just trying to avoid misunderstanding your requirements and ending up with a query that doesn't really do what you need. Best, Oliver