?
Solved

Finding max value in a dataview column

Posted on 2006-07-02
4
Medium Priority
?
2,327 Views
Last Modified: 2008-02-01
I have a dataview for which I want to find the max value of a column from multiple rows. Is there a method to do this without having to loop through one row at a time?

Thanks.
0
Comment
Question by:Mr_Fulano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
ericwong27 earned 2000 total points
ID: 17029023

        ' Get the DefaultViewManager of a DataTable.
        Dim view As DataView = DataTable1.DefaultView

        ' Column sorted ascending.
        view.Sort = "NumberColumn DESC"
       
       ' The first row will be the max value
        Debug.WriteLine("Max : " & view(0)("NumberColumn").ToString)
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17029854
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17041056
hi


// C#

// The array rows will contain the row(s) that have the max value of SomeField. There could be more than one if two or more rows have the max value

DataRow[] rows = dataTable.Select("SomeField=Max(SomeField)");



// If you want to bind the result to a control then you can use a DataView

DataView view = new DataView(dataTable);

view.RowFilter = "SomeField=Max(SomeField)";

DataGrid.DataSource = view;

DataGrid.Bind();


this might help u : )






0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question