Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL question

Re: SQL question

From: Jan-Marten Spit <j.m.spit_at_uptime.nl>
Date: Thu, 25 Mar 1999 13:10:06 +0100
Message-ID: <7dd84d$35p$1@zonnetje.NL.net>


select
  1.field1,
   dummy.cnt
 from
  table1 1,
  table2 2,
  (select count(*) cnt, 2.field2 field2 from table2 2) dummy where
  1.field2=3.field1
  and
  1.field1=dummy.field2

You cannot use a nested query in the select list. You cannot reference values from other tables in the from clause. Must do this in the where clause.

Greetings, JM

Arno van Rossum wrote in message <36F8CC51.669167F1_at_mmp-obec.nl>...
>Hello,
>
>Recently I switched from MS SQL-server to Oracle8 but I've some troubles
>converting my stored procedures.
>
>In MS-SQLserver I use by example:
>
> SELECT 1.field1
> , 1.field2
> , (SELECT COUNT(*)
> FROM Table2 2
> WHERE 2.field2 = 1.field1) field3
> FROM Table1 1
> , Table3 3
> WHERE 1.field2 = 3.field1;
>
>But when I tried this in oracle it says I can't use a nested select.
>
>In oracle I tried:
>
> SELECT 1.field1
> , 1.field2
> , field3
> FROM Table1 1
> , Table3 3
> WHERE 1.field2 = 3.field1
> AND field3 = (SELECT COUNT(*)
> FROM Table2 2
> WHERE 2.field2 = 1.field1
> );
>
>but the above statement gives the error that field3 (in the where
>clause) is not known.
>
>Declaring field3 as a local variable in the stored procedure gives no
>errors, but then it selects nothing at all.
>
>Is there someone who can help me translate the above MSSQL-server
>statement to Oracle 8?
>
>Thanks,
>
>Arno van Rossum
>(A.van.Rossum_at_mmp-obec.nl)
Received on Thu Mar 25 1999 - 06:10:06 CST

Original text of this message

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