Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Subquery in the Where clause

orclrunnerFeb 22 2006 — edited Feb 23 2006

Can I put a subquery in the where clause, on the left side on the operator?
This is a multi-row query.

Like this,

   select a.col1, a.col2, b.col1, b.col2,
             my_function(a.date1, b.date2) AS GROSSDAYS
   from table1 a
   where ( select ( a.date1 - b.date2 ) as range
               from     table1 a
               join      table2 b
               on       a.col3 = b.col3
               where rownum =1
           )
               in ( 1,2,3)
and  a.col1 = b.col2

I need to use a subquery because the column I need does not exist in the table, and I cannot make any changed to the table structure.

Is what I'm doing possible?

The subquery is the same as the function I have in the Select clause.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2006
Added on Feb 22 2006
11 comments
1,201 views