Exacute query against query

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.21

27/02/2007          3.10

27/02/2007          2.10                           Total: 7.41

28/02/2007          1.40

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
2/27/2007 3:19:09 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 20


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
2/27/2007 7:18:01 PM

Hi Dazza,

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!

Kevin Yu
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.
3/1/2007 3:32:58 AM

What if instead of performing calculations, you needed to query against a second table?

 For example, if I have a table that shows:

1   Fred

2   Tom

3   John

 And another table that shows:

1   A

1   B

2   A

2   C

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?

12/12/2007 7:40:44 PM