1

Can you please help me out with the below query? What I am looking for is a code to exclude items with wording '90003' from column COR_ID. So far I have a code that extracts data with date older than today from column VAL_DT, excluding items with wordings MAN, NOSTRO, SCREV and SCRIN for which query shows also dates newer than today.

All I need is for the below code is to remove '90003' from column COR_ID

WHERE 
    VAL_DT < CURRENT DATE AND COR_ID <> '90003'
    OR (   
       MVT_DS = 'NOSTRO' 
       OR MVT_DS = 'SCREV' 
       OR MVT_DS = 'SCRIN'
       OR MVT_DS = 'MAN' 
       )    
5
  • Are you using db2, another DBMS, or excel?
    – Erik
    Mar 18, 2016 at 14:25
  • Is there anything wrong with your current query? By the way, you seem to have used the solution provided for [your previous question]( dba.stackexchange.com/questions/132530/…) ; please consider marking the useful answer as accepted.
    – mustaccio
    Mar 18, 2016 at 14:26
  • I thought I have accepted the answer from previous question. I was advised by administrator to open a new question as my last question was not fully explained. The missing part is that I need to remove all items worded '90003' from entire query. I am downloading data from DB2 to excel
    – Tommeck37
    Mar 18, 2016 at 14:27
  • Do you want to exclude COR_ID = '90003' from the entire result set or just fronm the part where val_dt < current date? I also suggest in the query above to use " or MVT_DS in ('NOSTRO', 'SCREV', 'SCRIN', 'MAN') " which makes it mich more readable.... Mar 18, 2016 at 14:41
  • I need to remove all 90003 whether older or newer than today ... any
    – Tommeck37
    Mar 18, 2016 at 14:44

1 Answer 1

1

Following WHERE clause shold do the job

WHERE COR_ID <> '90003'
  AND (VAL_DT < CURRENT DATE  OR MVT_DS in ('NOSTRO', 'SCREV', 'SCRIN', 'MAN')  )
4
  • hello, I have copied and pasted the code run it and got error message. Nothing queried. Can you please check? Thank you
    – Tommeck37
    Mar 18, 2016 at 15:17
  • maybe the second closing bracket is the problem - I just saw it and corrected it Mar 18, 2016 at 15:18
  • works perfectly thank you. How I can give you a point?
    – Tommeck37
    Mar 18, 2016 at 15:19
  • great :-) - mark it as answer Mar 18, 2016 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.