Subject Port MySQL to Firebird - SQL syntax - can I do this?
Author johnrkebert
Hi all,

Presently I have an app with MySQL as backend and use a sql statement
that has 'if's in them, does Firebird/Interbase support this? or just
a syntax change? Here is what I have now:

SELECT
P.AppDate, P.AppName, CU.FULLNAME AS Customer, S.Initials,
Y.ANSWER AS Archived,
V.COMPANY AS Company, SUM(L.Acres) AS Acres, D.InsPerAcre,
DE.DEDRATE AS DeductRate,
A.RATE AS AreaRate, R.RATE AS CropRate, V.COMOVER5, V.COMMRATE,
V.PENNYCOMM, L.TWN,

SUM(IF(V.PENNYPREM=-1,
ROUND(((IF(V.1DECRATE=-1,
ROUND((A.RATE * R.RATE * DE.DEDRATE) + .0005, 2),
ROUND((A.RATE * R.RATE * DE.DEDRATE) + .005, 1)))
* L.ACRES * D.INSPERACRE / 100) + .05, 0),
ROUND((IF(V.1DECRATE = -1,
ROUND((A.RATE * R.RATE * DE.DEDRATE) + .0005, 2),
ROUND((A.RATE * R.RATE * DE.DEDRATE) + .005, 1)))
* L.ACRES * D.INSPERACRE / 100,2))) AS Premium

FROM DETAILS D
INNER JOIN POLICYAPP P ON D.POLICYAPPID=P.POLICYAPPID
INNER JOIN SALESAGENT S ON P.SALESAGENTID=S.SALESAGENTID
INNER JOIN CUSTOMER CU ON P.CUSTID=CU.CUSTID
INNER JOIN YESNO Y ON P.ARCHIVED=Y.ANSWERKEY
INNER JOIN DED DE ON D.DEDID=DE.DEDID
INNER JOIN LAND L ON D.LANDID=L.LANDID
INNER JOIN AREARATE A ON (L.TWN=A.TWN
AND L.RNG=A.RNG AND L.MER=A.MER)
INNER JOIN VENDOR V ON (A.VENDID=V.VENDID
AND A.VENDID=D.VENDID)
INNER JOIN CROP C ON L.CROPID=C.CROPID
INNER JOIN CROPRATE R ON (C.CROPID=R.CROPID
AND V.VENDID=R.VENDID)

Group by, where clause etc.

So I guess the question is, what is the Firebird/Interbase syntax for
the "As Premium" part of the select statement?

thanks,

John