0

I have the following query (in a Oracle Database):

          SELECT SUM (CANTITATE)
             FROM ANEXA2A_TABEL2_ROWS
            WHERE TIP_ACTIUNE = 'COLECTATE'
                  AND TIP_AMB = 'STICLA'
                  AND COD LIKE '%*'

The problem is that if I don't have any row with * in COD, the result is a empty cell and I want it 0. How can I do that?

Thanks!

1 Answer 1

0

Use NVL().

 SELECT NVL(SUM(CANTITATE),0)
             FROM ANEXA2A_TABEL2_ROWS
            WHERE TIP_ACTIUNE = 'COLECTATE'
                  AND TIP_AMB = 'STICLA'
                  AND COD LIKE '%*';

That'll make the SUM() function return 0 if it would ordinarily return NULL.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.