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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: ***Urgent Question***

RE: ***Urgent Question***

From: Amar Kumar Padhi <TS2017_at_emirates.com>
Date: Wed, 31 Jan 2001 07:13:03 -0800
Message-ID: <F001.002A5A53.20010131070528@fatcity.com>

in Oracle 8i....
SELECT COL1,COL2
FROM ( SELECT COL1,COL2

               FROM AM15
               GROUP BY COL1, COL2
               ORDER BY COL1 DESC, COL2 ASC)
WHERE ROWNUM < 8  

Amar Kumar Padhi
Software Consultant

-----Original Message-----
Sent: Wednesday, January 31, 2001 1:50 PM To: Multiple recipients of list ORACLE-L

Consider the following case.
TABLE : DEPT

empid             number,
deptid             number,
deptname        varchar2(30)

primary key (empid, deptid)  

now i want to fetch first seven records from a cursor whose deptid is maximum
and empid is minimum. kindly let me know how to write this cursor statement.for example.  

SQL> select deptid, empid from dept;  

 DEPTID EMPID

---------       ---------
        2     94204
        2     94205
        2     94206
        2     94207
        2     94208
        5     94209
        5     94210
        5     94211
        5     94212
        5     94213
        7     94214
        7     94215
        7     94216
        7     94217
        7     94218
 

15 rows selected.  

i want output as following by single query.  

 DEPTID EMPID

---------      ---------
        7     94214
        7     94215
        7     94216
        7     94217
        7     94218
        5     94209
        5     94210
 

7 rows selected  

kindly reply.. thanks in advance.  

regards
paresh mehta

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Amar Kumar Padhi
  INET: TS2017_at_emirates.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Wed Jan 31 2001 - 09:13:03 CST

Original text of this message

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