471,339 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

Min max from Dataset

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
Aug 21 '08 #1
3 3859
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

"Dan" <Da*@discussions.microsoft.comwrote in message
news:A8**********************************@microsof t.com...
>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

Aug 21 '08 #2
On Aug 21, 2:29*pm, "DaveL" <dvs_...@sbcglobal.netwrote:
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

"Dan" <D...@discussions.microsoft.comwrote in message

news:A8**********************************@microsof t.com...
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
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.
Aug 22 '08 #3
On 21 Aug., 22:55, Dan <D...@discussions.microsoft.comwrote:
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[i].ItemArray[columnIndex]);

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

hth,
Kevin Wienhold
Aug 22 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jeronimo Bertran | last post: by
5 posts views Thread by Mike | last post: by
3 posts views Thread by JJ | last post: by
5 posts views Thread by Jason | last post: by
2 posts views Thread by John Holmes | last post: by
15 posts views Thread by JIM.H. | last post: by
16 posts views Thread by Geoff Jones | last post: by
22 posts views Thread by Arne | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.