Re: Curious SQL question

From: Neo <neo55592_at_hotmail.com>
Date: 3 Jan 2007 14:08:43 -0800
Message-ID: <1167862123.309552.229210_at_i80g2000cwc.googlegroups.com>


> How does one identify those customers who bought no products at all?

Below is an alternate partial solution using dbd. John orders shampoo and soap. Mary orders soap and bread. No one orders wine. Queries returns what products John, Mary and any person did not order. Last query returns which persons did not order anything.

(new 'order 'verb)

(new 'shampoo 'product)
(new 'soap 'product)
(new 'bread 'product)
(new 'wine 'product)

(new 'john 'person)
(set john order shampoo)
(set john order soap)

(new 'mary 'person)
(set mary order soap)
(set mary order bread)

(new 'bob 'person)
(new 'sue 'person)

(; Get products not ordered by john)
(; Gets bread and wine)
(!= (get product instance *)

     (get john order *))

(; Get products not ordered by mary)
(; Gets shampoo and wine)
(!= (get product instance *)

     (get mary order *))

(; Get products not ordered by any person)
(; Gets wine)
(!= (get product instance *)

     (get (get person instance *) order *))

(; Get persons who did not order anything)
(; Gets bob and sue)
(!= (get person instance *)

    (get * order (get product instance *))) Received on Wed Jan 03 2007 - 23:08:43 CET

Original text of this message