I have a query which selects all dates from my database between 2 date values which is then entered into my dataset. I thin want to run through the dataset totalling the value of a certain column but only if dates match e.g.
27/02/2007 2.10 Total: 7.41
28/02/2007 4.40 Total: 5.80
And so on totalling together only the dates that match all the way through my dataset
Any help would be much appreciated Thanks Dazza22
Knowledge is not power it is a gift so lets share our gifts. Enjoy It
well i know that it is a common idea that any computing beyond a simple select, update, etc that computation shouldnt be done at the db through stored procedures. but you could have a stored procedure which returns the data that you want from the dataset. hope this may be of some help....--jp
If my post is helpful please mark as answer
Regards -- jp
For this kind of statistic operation, It will be better to do this on the database server. Here is an example. d stands for the Date column
SELECT d, sum(value) from Table_2 GROUP BY d
However, if you would like to do this in the DataSet, you can use DataTable.Select() method to return rows that is in the same date and accumulate one by one. But this will be much slower than the SQL statement.
HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
What if instead of performing calculations, you needed to query against a second table?
For example, if I have a table that shows:
And another table that shows:
and wanted something like this at the end:
Fred - A, B
Tom - A, C
I have tried using a data reader but because of the amount of records that my client wants to show, it is WAY too slow. I have tried pulling multiple datasets but am having issues trying to have one query against the other. Am I missing something easy?