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

Home -> Community -> Usenet -> c.d.o.misc -> A SQL quiz, tough one

A SQL quiz, tough one

From: L. Tseng <lesliet_at_u.washington.edu>
Date: 1997/04/19
Message-ID: <5j92dr$q0i@nntp6.u.washington.edu>#1/1

Hi, SQL experts,

There is a non-trivial SQL question for you... In the following code, what I intend to do is to select top 10 users with most network traffic volume and insert it into a table in DESC order for reporting purpose. as you can see, I marked two lines off because 'ROWNUM <= 10' clause generates a wrong data set and 'ORDER by' clause is not legal in a INSERT. So, any smart solutions for this?

Thanks for your help.
Leslie

                  INSERT INTO ReportTable
                   (
                    LogID,
                    GroupName,
                    NetUser,
                    Volume,
                   )
                   SELECT NameID,
                          GroupName,
                          Name,
                          SUM(BytesIn + BytesOut)
                     FROM TableA, TableB, TableC, TableD
                    WHERE ....
                         ...
                         ..
                    --  AND ROWNUM <= 10
                    GROUP BY NameID,
                             GroupName,
                             Name;
                    -- ORDER BY 4 DESC
Received on Sat Apr 19 1997 - 00:00:00 CDT

Original text of this message

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