Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: Removing re...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 3375 of 3799
Post > Topic >>

Re: Removing redundant itemsets

by craig@[EMAIL PROTECTED] (Craig Ringer) Mar 31, 2008 at 07:48 PM

> -- Find any `a' for which `item_from_a_is_in_b' is
> -- true for all items in `a'
> SELECT a_tid AS is_redundant, b_tid AS contained_by
> FROM (
>   -- For every item in every pair of purchases,
>   -- determine whether the item in purchase `a'
>   -- was also in purchase `b'.
>   SELECT
>     a.tid AS a_tid,
>     b.tid AS b_tid,
>     a.item AS item,
>     EXISTS(
>       -- Was this item from `a' also in the `b' purchase?
>       SELECT 1 FROM togo x WHERE x.tid = b.tid AND x.item = a.item
>     ) AS item_from_a_is_in_b
>   FROM togo a INNER JOIN togo b ON (a.tid <> b.tid)
>   GROUP BY a.tid, b.tid, a.item) AS item_containment
> GROUP BY a_tid, b_tid
> HAVING every(item_from_a_is_in_b);

That really should've been written as:

SELECT
  a.tid AS is_redundant,
  b.tid AS contained_by
FROM togo a INNER JOIN togo b ON (a.tid <> b.tid)
GROUP BY a.tid, b.tid
HAVING
  EVERY(EXISTS(
    SELECT 1 FROM togo x WHERE x.tid = b.tid AND x.item = a.item
  ));

.... but I'm a bit of an idiot, and couldn't figure out why the
EVERY(EXISTS(subq)) wasn't working when testing it before.

Sorry for all the noise.

--
Craig Ringer

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 5 Posts in Topic:
Removing redundant itemsets
allank@[EMAIL PROTECTED]   2008-03-31 10:16:17 
Re: Removing redundant itemsets
craig@[EMAIL PROTECTED]   2008-03-31 18:53:28 
Re: Removing redundant itemsets
craig@[EMAIL PROTECTED]   2008-03-31 19:29:22 
Re: Removing redundant itemsets
craig@[EMAIL PROTECTED]   2008-03-31 19:48:34 
Re: Removing redundant itemsets
allank@[EMAIL PROTECTED]   2008-03-31 11:58:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 22:30:01 CST 2008.