| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.oracle -> Re: Help Need for a Query
Prabu Krishnan wrote:
[snip]
> I need the Result as the following By a Single SQL Query
>
>
> EID ENAME
> ------ ----------
> 1001 John
> 1004 DO
> 1002 Gokul
> 1005 DO
> 1003 Daniel
> 1006 DO
This should get you started, but you should rewrite it so it used outer joins on subselects of the emp table, because the below sql would be painfully slow.
select
e.eid,
(select case when min(eid)=e.eid then ename else 'DO' end from emp
where ename=e.ename group by ename) ename
from emp e
order by (select min(eid) from emp where ename=e.ename group by ename),
e.eid
/Bent Received on Fri Jun 25 2004 - 06:49:16 CDT
![]() |
![]() |