[V4RB] Use of SUM command

Stan Busk maxprog at mac.com
Mon Jun 2 15:41:15 CDT 2003


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.

Thanks,
Stan



More information about the Valentina mailing list