Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query question
Not that that kind of query would make a lot of sense but here you go:
Note that you need to give rownum an alias, and the outer join (+) needs
to be on the table with fewer rows.
Christian
SQL> select ename, job, dname,loc from 2 (select ename,job,rownum cnt from emp) e, 3 (select dname,loc, rownum cnt from dept) d4 where e.cnt = d.cnt(+);
21 JAN 2000 07:59 page 1
ENAME JOB DNAME LOC ---------- --------- -------------- -------------
KING PRESIDENT ACCOUNTING NEW YORK BLAKE MANAGER RESEARCH DALLAS CLARK MANAGER SALES CHICAGO JONES MANAGER OPERATIONS BOSTON FORD ANALYST SMITH CLERK ALLEN SALESMAN WARD SALESMAN MARTIN SALESMAN SCOTT ANALYST TURNER SALESMAN ADAMS CLERK JAMES CLERK MILLER CLERK
GreyWolf_69 wrote:
>
> Hi,
> I was wondering if there was a way to have two different queries in
> a script
> that would write the results to the same line(s) in a file? The two
> queries don't have
> any common keys or fields.
>
> ex:
>
> query one: select name, id from emp;
> query two: select city, temp from forcast;
>
> ex of output that I'm looking for:
>
> name id city temp
> Don 001 Taos 85
>
> TIA,
>
> Grey
Received on Fri Jan 21 2000 - 10:20:37 CST