Subject Re: [firebird-support] using extract on null values
Author Dmitry Yemanov
Christian Kaufmann wrote:
>
> select distinct SR.COURSE, R.GENDER as RELAYGENDER, A.GENDER,
> extract(year from A.BIRTHDATE) as YOB
> from SWIMRESULT SR
> left join ATHLETE A on SR.ATHLETEID = A.ATHLETEID
> left join RELAYINFO R on SR.ATHLETEID = R.RELAYINFOID
>
> For records in SWIMRESULT where I have no record in ATHLETE, I get an
> error because "extract(year from A.BIRTHDATE)" fails.
>
> Is there a way, to get null or another default value for YOB in this case?

1) CASE
WHEN A.BIRTHDATE IS NULL THEN NULL
ELSE EXTRACT(YEAR FROM A.BIRTHDATE)
END

2) FB 2.0 returns NULL in your case


Dmitry