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 -> Re: using MAX function...

Re: using MAX function...

From: Doug O'Leary <dkoleary_at_mediaone.net>
Date: Wed, 8 Mar 2000 17:20:05 -0600
Message-ID: <MPG.13309c1f5f6cd01c989748@nntp.ce.mediaone.net>


In article <20000308161048.02477.00001226_at_ng-ca1.aol.com>, skurosky_at_aol.com says...

> One way to do it is:
> SELECT MAX(user_id),first_name,last_name
> FROM table_name
> GROUP BY user_id,first_name,last_name;
> HTH
> Sandy

I didn't think that was going to work, but I had to check. Using the renowned emp table for the example:

select max(empno), ename, job
from emp
group by empno, ename, job

produces:

MAX(EMPNO) ENAME JOB
---------- ---------- ---------

      7369 SMITH      CLERK
      7499 ALLEN      SALESMAN
      7521 WARD       SALESMAN
      7566 JONES      MANAGER
      7654 MARTIN     SALESMAN
      7698 BLAKE      MANAGER
      7782 CLARK      MANAGER
      7788 SCOTT      ANALYST
      7839 KING       PRESIDENT
      7844 TURNER     SALESMAN
      7876 ADAMS      CLERK
      7900 JAMES      CLERK
      7902 FORD       ANALYST
      7934 MILLER     CLERK
      8753 OLeary     Trainee

Not at all what the original poster was looking for.

The sql should be:

select empno, ename, job
from emp
where empno = (
 select max(empno)
 from emp);

which produces:

    EMPNO ENAME JOB
--------- ---------- ---------

     8753 OLeary Trainee

Doug
--



Douglas K. O'Leary
Senior System Admin
dkoleary_at_mediaone.net
Received on Wed Mar 08 2000 - 17:20:05 CST

Original text of this message

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