Case Statement Returning the same Value in many Instances

  • 25 January 2022
  • 1 reply
  • 45 views

Userlevel 1
Badge +7

The requirement was like this:


       CASE 
         WHEN SUBSTR(PART_NO, 1, 2) IN('XX', 'YY', 'ZZ')  THEN
           SUBSTR(PART_NO, 1, 2)
         ELSE
           'SP'
       END CODE,

See also >>

multiple values in case statement | Toolbox Tech


This topic has been closed for comments

1 reply

Userlevel 5
Badge +10

@waidyah , what is the exact requirement , as per the case statement , if the first 2 letters are in (‘XX’,’YY’,’ZZ’)  then it will return the first two letters which are going to be same , if not it will bring ‘SP’ . It depends on your data. try to analyze the data and explain the requirment clearly.