How do I use a previous condition on Oracle?

Asked

Viewed 27 times

0

I’m having a hard time using two columns as a condition in Where. I don’t know if I can explain it properly, but:

WHERE P.PROFILE_STATUS = '1' AND P.JOBTITLE NOT IN (' - Codrodrigo','Administrator','Manager','Support Staff','Test For Join - Codrodrigo') AND (P.JOBTITLE = 'SERVICE PROVIDER' AND SUBSTR(P.CORPORATE_ID,0,1) = 'P')

On line (P.JOBTITLE = 'SERVICE PROVIDER' AND SUBSTR(P.CORPORATE_ID,0,1) = 'P') I only want the lines that the first digit of the corporate id is equal to "P" when Jobtitle is 'SERVICE PROVIDER''.

But this scrip excludes all jobtitles that are different from 'SERVICE PROVIDER'. I want to exclude only those that are JOBTITLE = 'SERVICE PROVIDER' and that the first digit of the corporate id is equal to "P".

  • Try SUBSTR(P.CORPORATE_ID,1,1) = 'P')

  • I think you need to better define how to match your conditions. Maybe WHERE P.PROFILE_STATUS = '1' AND P.JOBTITLE NOT IN (' - Codrodrigo','Administrator','Manager','Support Staff','Test For Join - Codrodrigo') AND NOT (P.JOBTITLE = 'SERVICE PROVIDER' AND SUBSTR(P.CORPORATE_ID,0,1) = 'P') is what you’re looking for.

  • NOT solved! Very grateful @anonimo

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.