Subject | Re: [firebird-support] use of SUM |
---|---|
Author | Ivan Cruz |
Post date | 2005-07-05T19:19:12Z |
Sudheer Palaparambil wrote:
GROUP BY S.bill_no, S.discount
>Hi,Yes. But don't forget to...
>
> How to SUM the line_discount on line no.2 ?
>
>1. SELECT S.bill_no, S.discount, SUM( SD.line_value ),
>2. SUM( ( SD.line_value * SD.discount_p ) / 100 ) AS line_discount
>3. FROM sale S LEFT JOIN sale_det sd ON ( SD.company_id = S.company_id )
>4. AND ( SD.parent_id = S.id )
>5. WHERE ( ( S.company_id = :dCID ) AND ( S.entry_date = :dAsOn ) )
>
> Is this the correct way to sum ? Or should I use SUM for individual column
>
>
>
GROUP BY S.bill_no, S.discount
> like this ?No. It makes no sense to me.
>
> ( SUM( SD.line_value ) * SUM( SD.discount_p ) ) / 100 AS line_discount
>
>
>
> Since I am populating all numeric fields to non-null values, I am notIvan Cruz
> bothered about checking for NULL values here.
>
>
>