Help - Search - Members - Calendar
Full Version: help in datasets
AC Tools Everything Macro > AC Tool > AC Tool Discussion
quicksilver
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
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
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?



This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.