vendredi 11 novembre 2016

IF statement within a formula in a SQL query

Let's say I have a table with two numeric columns: NUM and DEN. I need to extract the ratio NUM/DEN only if DEN isn't 0: otherwise the ratio should be 0.

Something like this:

select ID, [...] AS RATIO
from Table 

where [...] is some kind of equivalent of the excel formula IF(DEN=0;0;NUM/DEN).

Is there a way to perform this kind of query?

Many thanks!

Aucun commentaire:

Enregistrer un commentaire