| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: anding across rows, how
stephen_james_at_uk2.net (Stephen James) wrote in message news:<dfd51415.0204130146.76b415cf_at_posting.google.com>...
> Given the data below how would I solve the following questions in SQL
> "What Customers have ordered both Carpets and Chairs and ..."
try
select clientid from clients c where exists (
select 1 from Orders o, Items i where c.orderid = o.orderid and o.itemid = i.itemid and i.type = 'CARPET' ) and exists ( select 1 from Orders o, Items i where c.orderid = o.orderid and o.itemid = i.itemid and i.type = 'CHAIR'
> "What Customers have ordered either Carpets and Chairs and ..."
select clientid from clients c where (exists (
select 1 from Orders o, Items i where c.orderid = o.orderid and o.itemid = i.itemid and i.type = 'CARPET' ) or exists ( select 1 from Orders o, Items i where c.orderid = o.orderid and o.itemid = i.itemid and i.type = 'CHAIR'
> "What Customers have ordered an item like 'C%' and ..."
select clientid from clients c where exists (
select 1 from Orders o, Items i where c.orderid = o.orderid and o.itemid = i.itemid and i.type like 'C%'
[...]
/Lennart Received on Sat Apr 13 2002 - 11:59:36 CDT
![]() |
![]() |