Min max from Dataset

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have a data set that I would like to get the min max for a column but only
from a range of records ie the 20th thru the 33rd record. Could someone point
me to some sytax to do this.

Thanks in advance - Dan
 
somthing like the below

select min(somecolumn), max(SomeColumn) from sometable (nolock)

where somecolumn >= somvalue and somecolumn <= somvalue

look at the Sql Between clause also

DaveL
 
somthing like the below

select min(somecolumn), max(SomeColumn) from sometable  (nolock)

where somecolumn >= somvalue and somecolumn <= somvalue

look at the Sql Between clause also

DaveL

Sorry, could you elaborate on what you want to achieve?
If I understand correctly, you're trying to get the row that has the
minimum value for some column in a table, and the same thing for the
row that has the maximum value.
DaveL posted code to get the value from a SQL Server database, but you
have a dataset, so it's much different (and easier!)
I'll post some code ASAP.

Also, if you do it your own way, don't forget to cast the values to an
int, so that C# knows how to compare the values.
 
I have a data set that I would like to get the min max for a column but only
from a range of records ie the 20th thru the 33rd record. Could someone point
me to some sytax to do this.

Thanks in advance - Dan

I'm assuming you mean DataTable, otherwise the question is not quite
clear.
If the values you want to compare are ints, something like this should
work:

for (int i = startIndex; i <= endIndex; i++)
{
int value = Convert.ToInt32(table.Rows.ItemArray[columnIndex]);

if (value > highest)
{
highest = value;
}
else if (value < lowest)
{
lowest = value;
}
}

hth,
Kevin Wienhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top