This is my table:
ID COUNTRY_CODE_3D COUNTRY_CODE_2D TYPE_ID
1 "IND" "IN" 11
2 "CAN" "CA" 13
3 null null 17
I want a select query which will return a single row
if COUNTRY_CODE_2D = 'CA' (valid data) return 2nd row, else return the 3rd row where COUNTRY_CODE_2D =null and TYPE_ID=17
If you can put a functional index on country_code_2d, (
NVL(country_code_2d,'EMPTY')),you can then
Or Without joins (and more portable as it does not use the oracle table
DUAL)