sql problem

From: lancelot <afernique_at_tims.fr.no_spam>
Date: Mon, 25 May 1998 18:57:58 +0200
Message-ID: <3569A316.E0A661C4_at_tims.fr.no_spam>



I have a problem in an sql select
I try to access a value which we can call "VAL" in an exist clause of the select.
I can access it from the exist select but not from select within.

Here's the example
This code works:
SELECT
 R1."VAL"
FROM
(

 SELECT
  1 "VAL"
 FROM
  DUAL
 UNION
 SELECT
  2 "VAL"
 FROM
  DUAL
 ) R1
WHERE
 0 =
  (
  SELECT
   COUNT(*)
  FROM
   (
   SELECT
    1
   FROM
    DUAL
   ) R2
  WHERE
   R1."VAL" = 1
  )
and returns 2 because when val has a value of 1 the return of exist differ from 0
.
but if I put the where in the inside select SELECT
 R1."VAL"
FROM
(

 SELECT
  1 "VAL"
 FROM
  DUAL
 UNION
 SELECT
  2 "VAL"
 FROM
  DUAL
 ) R1
WHERE
 0 =
  (
  SELECT
   COUNT(*)
  FROM
   (
   SELECT
    1
   FROM
    DUAL
   WHERE
    R1."VAL" = 1
   ) R2
  )
It does not work anymore. Seems it does not know R1 table?

Anybody's got a clue on this one?

Pleaz erase the no_spam in my e-mail address when direct replying :) Received on Mon May 25 1998 - 18:57:58 CEST

Original text of this message