[V4RB] Use of SUM command <-FIXED!

Stan Busk maxprog at mac.com
Mon Jun 2 17:16:17 CDT 2003


Hi,

Forget it! I found out. I was using aCursor.DoubleField(2).value rather 
than second record aCursor.DoubleField(1).value . Weather is starting 
to be to hot for me here... :-/

Stan

> Hi,
>
> Thanks. That was what I was thinking about but it doesn't work. The 
> cursor always return one only record. I have tried many times with 
> different variation but no way. What can prevent the cursor to return 
> second record? I am using V4RB 1.9.8b7 with a database that works fine 
> with all kind of queries.
>
> Stan
>
>> 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 ]
>> -------------------------------------------------------------
>>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>
>



More information about the Valentina mailing list