AS400 SQL : Case When
Scenario:
Container field in CONT file is build as Julian Day (3 Digit)+ 6 Digit sequence number. Julian Day (3 Char) is also field in CONT file. Below query will identify all the records that are having Jul_Day and first 3 digit are not matching using Case when condition.
Container field in CONT file is build as Julian Day (3 Digit)+ 6 Digit sequence number. Julian Day (3 Char) is also field in CONT file. Below query will identify all the records that are having Jul_Day and first 3 digit are not matching using Case when condition.
select * from Cont
where
int(Jul_Day) <> case
when length(trim(char(container))) = 8
then
int(substr(char(container),1,2))
when
length(trim(char(container))) = 7
then
int(substr(char(container),1,1))
Else
int(substr(char(container),1,3)) end
Comments
Post a Comment