April 6, 2011

Use Decode and Substr

Using Decode and substr together:- 
Decode wil replace the IF-THEN-ELSE
e.g
SELECT full_name,
decode(Current_employee_flag, 'Y', 'EMP',
 'N', 'Not Emp')result
FROM per_all_people_f;
Substr will filter values to the length you specify
Eg
SELECT SUBSTR('Take the first four characters', 1, 4) FIRST_FOUR
FROM dual;

To use both:
SUM(DECODE(Substr(piv.uom, 1, 1), 'M', prrv.result_value, NULL))  amount,

Will result value will grouped for numeric values.

No comments:

Post a Comment

Thanks for your comments submitted.,will review and Post soon! by admin.

Part of my Oracle Fusion HCM Fix of the Day series: real issues from implementations and a Redwood rollout I led without a Systems Integrat...