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!

how to use Relational Operater as parameter in Where clause

Ahmed HaroonJan 11 2017 — edited Jan 11 2017

hi all,

I want to use Relational Operator in Where clause but as Parameter, how I can do it? below is the working i tried to achieve but it is showing error

ORA-00920: invalid relational operator

can i use CASE here to check like this:  CASE WHEN :bal = 'G' THEN '>' WHEN :bal = 'E' THEN '=' WHEN :bal = 'L' THEN '<' END

select cust_id, amt from (      

with mytab as (Select 1 cust_id, 100 amt from dual

              union all

              select 1, 50 from dual

              union all

              select 2, 10 from dual

              union all

              select 2, -10 from dual

              union all

              select 3, 50 from dual

              union all

              select 3, -60 from dual

             )

select cust_id, sum(amt) amt

from mytab

group by cust_id

)

where amt :bal 0

please help.

regards

This post has been answered by Cookiemonster76 on Jan 11 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2017
Added on Jan 11 2017
7 comments
470 views