vendredi 27 avril 2018

SQL SELECT depending on value

I need advise or an idea how to solve my problem. I have select based on few joins. One of the selected value is ex. CA.PADDING_ZERO_FLAG which is '0' or '1'.

Based on this, I want to get other values in select statement.

Pseudocode:

Select if(CA.PADDING_ZERO_FLAG = '1') then LPAD(ZR.START_ZIP_CODE, 5, '0'),
    LPAD(ZR.END_ZIP_CODE, 5, '0') else ZR.START_ZIP_CODE, ZR.END_ZIP_CODE

Is it possible to do?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire