Results 1 to 5 of 5

Thread: find max, min, sum of a column?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    southwest pennsylvania
    Posts
    65

    find max, min, sum of a column?

    i have a datatable with a column of doubles.

    how would i find the largest and smallest double in the column, and add the column? i dont want to loop through it... that's too easy
    if you choose not to decide you still have made a choice!

    RUSH rocks!

  2. #2
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Sort the column and then pick up the first and the last item.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    southwest pennsylvania
    Posts
    65
    will that affect the output when i apply it to a datagrid? i dont want it to be sorted in the output.
    if you choose not to decide you still have made a choice!

    RUSH rocks!

  4. #4
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336

    Shot in the dark...

    Well, if you're getting the list of values from a database table, could you not execute a second query such as...
    Code:
    SELECT MAX(dbo.Table1.Value), MIN(dbo.Table1.Value), SUM(dbo.Table1.Value) FROM dbo.Table1
    ...to get the calculations you're after?
    Another satisfied customer

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Location
    southwest pennsylvania
    Posts
    65
    i'm not using a database table. i'm populating the datatable using other calculations.

    btw - i dont know what a database table is and how to use it either
    if you choose not to decide you still have made a choice!

    RUSH rocks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width