Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Fun Challenge #2

Re: SQL Fun Challenge #2

From: Noel <tbal_at_go2.pl>
Date: Thu, 4 Mar 2004 10:24:15 -0000
Message-ID: <c26scg$763$1@inews.gazeta.pl>


> Create a table, load it with data, and write a single SQL statement to
> produce the data set required to deduce the answer ... then deduce away!

The solution is somhere here...
I skip creating tables...

--
 SELECT X Youngest,Y MiddleAge, Z Oldest
  FROM
      (
      SELECT ROWNUM X
        FROM ALL_TABLES
       WHERE ROWNUM < 20
      ),
      (
      SELECT ROWNUM Y
        FROM ALL_TABLES
       WHERE ROWNUM < 20
      ),
      (
     SELECT ROWNUM Z
       FROM ALL_TABLES
      WHERE ROWNUM < 20
      )
     WHERE X * Y * Z = 36
       AND X<=Y
       AND Y<Z
       AND X<Z
       AND (X+Y+Z) =
           (
           SELECT  X + Y + Z
             FROM
               (
            SELECT ROWNUM X
              FROM ALL_TABLES
             WHERE ROWNUM < 20
               ),
               (
           SELECT ROWNUM Y
             FROM ALL_TABLES
            WHERE ROWNUM < 20
              ),


           SELECT ROWNUM Z
             FROM ALL_TABLES
            WHERE ROWNUM < 20
              )
         WHERE X * Y * Z = 36
           AND X<=Y
           AND Y<=Z
        GROUP BY X+Y+Z
        HAVING COUNT(*) > 1
        );

--
Noel
Received on Thu Mar 04 2004 - 04:24:15 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US