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: A little complicated SQL

Re: A little complicated SQL

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Thu, 18 Jul 2002 15:18:12 GMT
Message-ID: <3D36DBF8.3003E08E@exesolutions.com>


Alex Kizub wrote:

> I want to improve perfomance of my application but database structure
> is not good.
>
> Here is problemm:
>
> One SQL is:
> select A,B from T1;
>
> for each row I have to create another query
> select C from X1,X2 where X1.A=A and X2.B=B and X1.D=X2.D;
>
> X1.A can be absent, X2.B can be absent and relation X1.D=X2.D can be
> absent.
>
> So I can have something or nothing.
>
> So right now I have rowset like this
>
> A B Query C
> -------------------------------------------------------------------------------------------------
> A1 B1 select C from X1,X2 where X1.A='A1' and X2.B='B1' and
> X1.D=X2.D C1
> A2 B2 select C from X1,X2 where X1.A='A2' and X2.B='B2' and
> X1.D=X2.D nothing
> A3 B3 select C from X1,X2 where X1.A='A3' and X2.B='B3' and
> X1.D=X2.D C3
>
> Can I create query which returns for me
>
> A B C
> ------------------------------
> A1 B1 C1
> A2 B2 null
> A3 B3 C3
>
> in one select statement?
> And I can't use PL/SQL in our database :(
>
> Thanks is advance.
>
> Alex Kizub.

Go to http://tahiti.oracle.com and search on the following criteria:

  1. In-line views
  2. Sub-queries

I apologize in advance if my assumption is incorrect. But when you say "can't use PL/SQL in our database" I read it as being one of the following:

  1. The teacher of your class wants you to do this with SQL
  2. The teacher of your class wants you to do this with SQL
  3. The teacher of your class wants you to do this with SQL

... and I don't think it is proper for us to do your homework for you.

Daniel Morgan Received on Thu Jul 18 2002 - 10:18:12 CDT

Original text of this message

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