| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Curious SQL question
Tonkuma wrote:
> Or
> ------------------------- Commands Entered -------------------------
> SELECT Customer_ID, Product_ID
> FROM (SELECT C.Customer_ID, P.Product_ID
> FROM (SELECT DISTINCT
> Customer_ID
> FROM GutoSupplied.Orders) C
> INNER JOIN
> GutoSupplied.Products P
> ON 0=0
> ) CP
> EXCEPT
> SELECT O.Customer_ID, P.Product_ID
> FROM GutoSupplied.Orders O
> INNER JOIN
> GutoSupplied.Products P
> ON O.Product_ID = P.Product_ID
> ORDER BY
> Customer_ID, Product_ID;
> ------------------------------------------------------------------------------
>
Remove redundncy of my second example.
------------------------- Commands Entered -------------------------(
FROM (SELECT DISTINCT
Customer_ID
FROM GutoSupplied.Orders) C
INNER JOIN
GutoSupplied.Products P
ON 0=0
CUSTOMER_ID PRODUCT_ID
----------- -----------
1 5
2 3
2 4
2 5
3 2
3 5
4 1
4 2
4 3
4 4
10 record(s) selected. Received on Sat Jan 06 2007 - 11:26:57 CST
![]() |
![]() |