Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: using MAX function...
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
--