• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

How to convert simple Oracle SQL statement into MS SQL Server SQL statement

I want to convert sql statement from oracle sql to ms sql server sql:
select *
from REN
where (ko,st_pc,stev_pc,imen_pc) not in (
            select  ko,st_pc,stev_pc,imen_pc
            from REN
            where raba_id = 1
              and POV_KS > 70)
0
Premanidhi
Asked:
Premanidhi
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the following 2 options should work in both oracle AND ms sql server:

select *
from REN t
left join REN o
  on t.ko = o.ko
 and t.st_pc = o.st_pc
 and t.stev_pc = o.stev_pc
 and t.imen_pc = o.imen_pc
 and o.raba_id = 1
 and o.pov_ks > 70
where o.ko is null


or:

select *
from REN t
where not exists (
 select null
  from REN o
 where t.ko = o.ko
 and t.st_pc = o.st_pc
 and t.stev_pc = o.stev_pc
 and t.imen_pc = o.imen_pc
 and o.raba_id = 1
 and o.pov_ks > 70
)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now