Hi all
I think an example will explain my problem the best.
I have the following SQL select statement:
select (sum(sold) - sum(paid)) as duty
from clients
join sold on sold.client_id=clients.id
join paid on paid.client_id=clients.id
where clients.id=<whatever>
The obvous problem is that if a certain client never paid anything, sum(paid) returns null, so sum(sold)-sum(paid) returns null instead of sum(sold).
What I want is a function like NVL or ISNULL equivalent in Interbase or if someone knows a workaround to make my select return a 0 if the value is null. In SQL Server it would look as follows:
select (sum(sold) - isnull(sum(paid), 0)) as duty
from clients
join sold on sold.client_id=clients.id
join paid on paid.client_id=clients.id
where clients.id=<whatever>
Hope this makes sence and someone can help me out there.
Thank you everybody.
I think an example will explain my problem the best.
I have the following SQL select statement:
select (sum(sold) - sum(paid)) as duty
from clients
join sold on sold.client_id=clients.id
join paid on paid.client_id=clients.id
where clients.id=<whatever>
The obvous problem is that if a certain client never paid anything, sum(paid) returns null, so sum(sold)-sum(paid) returns null instead of sum(sold).
What I want is a function like NVL or ISNULL equivalent in Interbase or if someone knows a workaround to make my select return a 0 if the value is null. In SQL Server it would look as follows:
select (sum(sold) - isnull(sum(paid), 0)) as duty
from clients
join sold on sold.client_id=clients.id
join paid on paid.client_id=clients.id
where clients.id=<whatever>
Hope this makes sence and someone can help me out there.
Thank you everybody.