Subject | Re: [ib-support] Count value on field |
---|---|
Author | Martijn Tonies |
Post date | 2002-03-20T14:27:30Z |
Probably because the SQL standard says about SUM/COUNT/AVG etc:
General Rules
1) Case:
a) If COUNT(*) is specified, then the result is the cardinality
of T.
b) Otherwise, let TX be the single-column table that is the
result of applying the <value expression> to each row of T
and eliminating null values. If one or more null values are
eliminated, then a completion condition is raised: warning-
null value eliminated in set function.
I think case 'b' applies here --> the rows with NULLs are eliminated first,
and then SUM is applied.
Do not that using SUM(rows) is a totally different operation compared to
col1+col2+col3
SUM is a SQL function while + is an arithmic operation...
--
Martijn Tonies
Upscene Productions
InterBase Workbench - The Developer Tool for InterBase
http://www.interbaseworkbench.com
"Experience is what you get when you didn't get what you wanted"
""Bayu"" <bayu2000@te m.net> schreef in bericht
news:004301c1d018$3064f600$2c6c053d@bayu01...
General Rules
1) Case:
a) If COUNT(*) is specified, then the result is the cardinality
of T.
b) Otherwise, let TX be the single-column table that is the
result of applying the <value expression> to each row of T
and eliminating null values. If one or more null values are
eliminated, then a completion condition is raised: warning-
null value eliminated in set function.
I think case 'b' applies here --> the rows with NULLs are eliminated first,
and then SUM is applied.
Do not that using SUM(rows) is a totally different operation compared to
col1+col2+col3
SUM is a SQL function while + is an arithmic operation...
--
Martijn Tonies
Upscene Productions
InterBase Workbench - The Developer Tool for InterBase
http://www.interbaseworkbench.com
"Experience is what you get when you didn't get what you wanted"
""Bayu"" <bayu2000@te m.net> schreef in bericht
news:004301c1d018$3064f600$2c6c053d@bayu01...
> Hello Martin and Luc
>
> > NULL means the state of 'unknown'.
> >
> > value + unknown = unknown
>
> But why select sum(d_imip) from transaksi will give me the right result ?
>
> > If you want your empty columns to behave as 0, better make sure they are
> 0.
>
> No. For some reason this field is null permited.
>
> > If this behaviour is only wanted for the sake or summing the fields, try
> the
> > new Firebird User Defined Functions - see www.firebirdsql.org for more
> info
> > on those (release notes for FB1)
>
> What kind of UDF do you mean ?
>
> regards
>
> Bayu
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>