Re: all the table values equal

Поиск
Список
Период
Сортировка
От negora
Тема Re: all the table values equal
Дата
Msg-id 4C986A03.4030403@negora.com
обсуждение исходный текст
Ответ на Re: all the table values equal  (Michele Petrazzo - Unipex <michele.petrazzo@unipex.it>)
Список pgsql-sql
<font face="Verdana">I'm not sure if I understood you right, but it sounds similar to a case which I faced recently.
Whynot to use an inverse approach? In other words: trying to find those registries which hasn't got at least one value
whichdiffers from which you want to look for. How? Using the EXISTS function with some kind of subquery I guess.<br
/><br/><br /></font><br /> On 21/09/10 10:11, Michele Petrazzo - Unipex wrote: <blockquote
cite="mid:4C9868AB.6050200@unipex.it"type="cite">Oliveiros d'Azevedo Cristina ha scritto: <br /><blockquote
type="cite">Helloagain, Michele, <br /><br /></blockquote><br /> Ciao, <br /><br /><blockquote type="cite">I haven't
openmy mailbox during weekend so I couldn't follow up your <br /> question. <br /><br /></blockquote><br /> No problem!
<br/><br /><blockquote type="cite">It would help if you explain a little better the background of the <br /> problem
you'retrying to solve. <br /><br /> You want to find all the user IDs which have the same value on a <br /> given time
interval?<br /><br /> Is my understanding correct? <br /><br /></blockquote><br /> Yes. <br /><br /> Re-reading my post
Isaw that I could explain better! <br /><br /> id_user | value | datetime <br /> 1 | 1 | xxx <br /> 1 | 2 | xxx+1 <br
/>1 | -1 | xxx+2 <br /> 2 | -1 | xxx <br /> 2 | -1 | xxx+1 <br /> 3 | 4 | xxx <br /> 3 | 10 | xxx+1 <br /> 3 | 4 |
xxx+2<br /> 4 | 3 | xxx <br /> 4 | 3 | xxx+1 <br /><br /> So, the new question: how I can find which id_user has _all_
the"value" <br /> that I'm looking for? Say -1 as 3 and I want a id_user=2 for the first <br /> and for the latter
id_user=4<br /><br /><br /> Thanks, <br /> Michele <br /><br /><blockquote type="cite">Best, Oliver <br /><br /> -----
OriginalMessage ----- From: "Michele Petrazzo - Unipex" <br /><a class="moz-txt-link-rfc2396E"
href="mailto:michele.petrazzo@unipex.it"><michele.petrazzo@unipex.it></a>To: "Oliveiros d'Azevedo Cristina" <br
/><aclass="moz-txt-link-rfc2396E"
href="mailto:oliveiros.cristina@marktest.pt"><oliveiros.cristina@marktest.pt></a>Cc: <a
class="moz-txt-link-rfc2396E"href="mailto:pgsql-sql@postgresql.org"><pgsql-sql@postgresql.org></a> Sent: <br />
Friday,September 17, 2010 4:45 PM Subject: Re: [SQL] all the table <br /> values equal <br /><br /><br /><blockquote
type="cite">Oliveirosd'Azevedo Cristina ha scritto: <br /><blockquote type="cite">Howdy , Michele, <br /><br /> Give
thisa try <br /><br /> SELECT id_user FROM t_your_table WHERE datetime BETWEEN A -- <br /> plug here beginning of
intervalAND B -- and end here GROUP BY <br /> id_user HAVING COUNT(*) = -SUM(value) <br /><br /> Then tell me if it
givesyou what you want <br /></blockquote><br /><br /> Thanks, it works, but... it's really a trickle that exploits the
<br/> value -1 if I understand how its work. If there is another value <br /> where look for? Example 13? <br /><br />
Thanks<br /><br /> -- Sent via pgsql-sql mailing list (<a class="moz-txt-link-abbreviated"
href="mailto:pgsql-sql@postgresql.org">pgsql-sql@postgresql.org</a>)To <br /> make changes to your subscription: <br
/><aclass="moz-txt-link-freetext"
href="http://www.postgresql.org/mailpref/pgsql-sql">http://www.postgresql.org/mailpref/pgsql-sql</a><br
/></blockquote><br/><br /></blockquote><br /><br /><br /></blockquote> 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Michele Petrazzo - Unipex
Дата:
Сообщение: Re: all the table values equal
Следующее
От: "Oliveiros d'Azevedo Cristina"
Дата:
Сообщение: Re: all the table values equal