Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: Storing function value in variable

    I want to use the value of a complex function several times within a query. I had thought I could do something like:

    SELECT (...complex function...) as x,
    log(x) as log_x
    FROM somewhere
    WHERE x > 3
    AND x <= 10
    OR ....(more uses of x)

    But this doesn't work.

    What do you suggest?

    Thanks in advance!
    -David

  2. #2
    Join Date
    May 2003
    Posts
    87
    You can use the function in the from clause to return the value and access it in the query multiple times.

    SELECT x, log(x) as log_x
    FROM somewhere, (select f_cmplx as x from dual) b
    WHERE x > 3
    AND x <= 10
    OR ....(more uses of x)
    /

  3. #3
    Join Date
    Oct 2003
    Posts
    6
    That worked! Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •