quicksilver
May 26 2009, 04:11 AM
i just started to play a little with DS and i wondered is there a faster way to count severals rows (values) in same column or you must go row row count it and then compute it? ( i don't mean how many rows i have active but computing there values)
thanks :>
lior
Ipa
May 26 2009, 05:51 PM
In a SQL database, you'd use an aggregate function to do this - eg SUM(), AVG(), MIN(), MAX() etc.
SELECT SUM(YourField) As TotalAmount
FROM YourTable
ACTool datasets unfortunately don't support SQL syntax, so you need to roll your own. If you're doing this frequently, you should consider parameterized procedures that encapsulate the functionality so you're not copy/pasting the code all over.
Eg
Procedure SumDataset Using DatasetName, Fieldname
DSFirst $DatasetName
While not eof
calc running total etc
DSNext
End
End
quicksilver
May 28 2009, 06:31 AM
thanks a lot for the answer Ipa , im in middle of coding my first long complicated macro and i just saw in your answer the use of "using" command in the Procedure
and reread the Procedure help file , my question is: when you coding do you prefer to use few generic constants or use the "using Procedure" in general instead of just Procedure?