Subject | IB dumber than a $5 calculator |
---|---|
Author | csswa |
Post date | 2002-05-30T03:44:43Z |
I'm not fond of Interbase's casting. Right now I consider
Interbase's handling of arithmetic to be dumber than a $5
calculator. Sure, it's great for completely controlling every step
of the computational process, but is it really necessary to have to
CAST every single element of formula to ensure correct results?
There's got to be an easier way. Why not just internally cast every
computed constant/variable to the output variable type? e.g. if the
result is a double precision then internally cast all parts of the
computation to a double. If the result is a string, then type all to
string, etc.
It's enough to make me dump IB and embrace MSSQL (hell just froze
over). Or does MSSQL force you to be this finnicky when coding
stored procedures?
Gripe over. If anyone can suggest how to streamline the below
select, much appreciated.
Regards,
Andrew Ferguson
-- tag omitted due to complete lack of humour today :-)
SELECT
F_CUSTNAME AS CUSTNAME,
F_UNITNO AS UNITNO,
COUNT(F_SAMPLE_ID) AS TOTAL_SAMPLES,
MIN(F_PROCESSDATE) AS FIRST_SAMPLE,
MAX(F_PROCESSDATE) AS LATEST_SAMPLE,
MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE) AS DAY_RANGE,
CAST (COUNT(F_SAMPLE_ID) AS DOUBLE PRECISION)
/
CAST((MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE)) AS DOUBLE PRECISION)
AS AV_SAMP_PER_MTH
FROM T_LIMZ1_SAMPLES
GROUP BY
F_CUSTNAME,
F_UNITNO
HAVING (MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE)) > 0
ORDER BY 1,3 DESC
;
Interbase's handling of arithmetic to be dumber than a $5
calculator. Sure, it's great for completely controlling every step
of the computational process, but is it really necessary to have to
CAST every single element of formula to ensure correct results?
There's got to be an easier way. Why not just internally cast every
computed constant/variable to the output variable type? e.g. if the
result is a double precision then internally cast all parts of the
computation to a double. If the result is a string, then type all to
string, etc.
It's enough to make me dump IB and embrace MSSQL (hell just froze
over). Or does MSSQL force you to be this finnicky when coding
stored procedures?
Gripe over. If anyone can suggest how to streamline the below
select, much appreciated.
Regards,
Andrew Ferguson
-- tag omitted due to complete lack of humour today :-)
SELECT
F_CUSTNAME AS CUSTNAME,
F_UNITNO AS UNITNO,
COUNT(F_SAMPLE_ID) AS TOTAL_SAMPLES,
MIN(F_PROCESSDATE) AS FIRST_SAMPLE,
MAX(F_PROCESSDATE) AS LATEST_SAMPLE,
MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE) AS DAY_RANGE,
CAST (COUNT(F_SAMPLE_ID) AS DOUBLE PRECISION)
/
CAST((MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE)) AS DOUBLE PRECISION)
AS AV_SAMP_PER_MTH
FROM T_LIMZ1_SAMPLES
GROUP BY
F_CUSTNAME,
F_UNITNO
HAVING (MAX(F_PROCESSDATE) - MIN(F_PROCESSDATE)) > 0
ORDER BY 1,3 DESC
;