Subject Re: [firebird-support] Re: view porting problem
Author Arno Brinkman
Hi,

> My question is how can I port this SQL statement from MSSQL to
> Firebird:
>
> (case
> when isnull(EC_UsrID, 0) <> 0 then EC_UsrTS
> when isnull(KV_UsrID, 0) <> 0 then KV_UsrTS
> when isnull(OE_UsrID, 0) <> 0 then OE_UsrTS
> when isnull(MD_UsrID, 0) <> 0 then MD_UsrTS
> else 0 end) as StatusTS
>
> Does someone know how?

(CASE
WHEN COALESCE(EC_UsrID, 0) <> 0 THEN EC_UsrTS
WHEN COALESCE(KV_UsrID, 0) <> 0 THEN KV_UsrTS
WHEN COALESCE(OE_UsrID, 0) <> 0 THEN OE_UsrTS
WHEN COALESCE(MD_UsrID, 0) <> 0 THEN MD_UsrTS
ELSE 0
END) as StatusTS

or if EC_UsrID, KV_UsrID, OE_UsrID and MD_UsrID never has the value 0 (zero)
then :

(CASE
WHEN EC_UsrID IS NOT NULL THEN EC_UsrTS
WHEN KV_UsrID IS NOT NULL THEN KV_UsrTS
WHEN OE_UsrID IS NOT NULL THEN OE_UsrTS
WHEN MD_UsrID IS NOT NULL THEN MD_UsrTS
ELSE 0
END) as StatusTS

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://80.126.130.81