[V4RB] Use of SUM command

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Jun 2 17:19:26 CDT 2003


on 6/2/03 16:41, Stan Busk at maxprog at mac.com wrote:

> Hi,
> 
> I am trying to optimize some of my database calculations. For example I
> use the SUM command twice because depending on 'Type' I have to change
> the sign. These are the SQL commands:
> 
> aCursor = vdb.SQLselect("Select Sum(Amount) from Accs where Type='2'")
> bCursor = vdb.SQLselect("Select Sum(Amount) from Accs where Type='3'")
> 
> And the result:
> 
> Result = - aCursor.DoubleField(1).value - bCursor.DoubleField(1).value
> 
> Is there a way to make this calculation in one SQL command? I have
> found stuff inside the Doc but no examples. I guess this is the GROUP
> command but I have absolutely no clue of how it works, documentation
> has no mention about it.

Hi Stan,

    SELECT Sum(Amount)
    FROM Accs
    WHERE Type='2' OR Type='3'
    GROUP BY Type

You should get cursor with 2 records now.
Read values from each record and do calculation self.

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list