CASE or any UDF to select values

Database

CASE or any UDF to select values

Need to select/pick a value to load into another table using below conditions - can someone help and throw some ideas -

AAA-1 and AAA-2 are DECIMAL(6,0) - Values range from 0 to 999,999

Condition:

IF AAA-1 has at least 4 digits (excluding right padded 0's) and starts with 52 then use it else

IF AAA-2 has at least 4 digits (excluding right padded 0's) and starts with 52 then use it else

Thanks

HM

Tags (1)
1 REPLY
Enthusiast

Re: CASE or any UDF to select values

Hi HMarella,

Your explanation is not clear. Why dont you provide more detials with sample data/expected result.

If you want to filter the data based on range criteria, you may use

CASE WHEN AAA-1 BETWEEN 52 AND 9999 THEN AAA-1 ELSE

CASE WHEN AAA-2 BETWEEN 52 AND 9999 THEN AAA-2 ELSE  'NONE' END 

END

Thanks,

Narasimha Sarma.