I have a VB VSE 2005 project in which I need to rank about 35 columns of
numbers. I want to end up with a dataset of ordinals. For example, if I have
a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7
respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array
and then walk through each column to calculate the ordinal and place it in a
second array. When I have all the ordinals I put the array data into a
dataset (I need a dataset to pass to the reporting code). Is there a better
way to accomplish this?
TIA
Wayne 7 1084
Perhaps a list would do what you need. Each list item would contain a value
( countValue ), this way you could do something like
PSEUDO CODE
For Each Value in your collection
If List contains key, then Add 1 to value else create new Item with
value of 1
End Loop
Bubble Sort List.
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl... I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
Hi,
If you are getting the data from a sql server 2005 database you
can use the row_number() over (order by colA) to create the ordinal. Here is
a simple example.
Dim strConn As String
Dim da As SqlDataAdapter
Dim conn As SqlConnection
Dim ds As New DataSet
strConn = "Server = (local)\SQLEXPRESS;"
strConn &= "Database = NorthWind; Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select Row_Number() Over(Order by
CustomerID) as MyOrdinal, * From Customers", conn)
da.Fill(ds, "Customers")
DataGridView1.DataSource = ds.Tables("Customers")
Ken
----------------------------------------
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl... I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
Thanks for the response. I am not sure exactly what you are suggesting here?
In the pseudo code, what is "key" in "If list contains key.."
Wayne
"Mr Newbie" <he**@now.com> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl... Perhaps a list would do what you need. Each list item would contain a value ( countValue ), this way you could do something like
PSEUDO CODE For Each Value in your collection If List contains key, then Add 1 to value else create new Item with value of 1 End Loop
Bubble Sort List. "Wayne Wengert" <wa***********@wengert.org> wrote in message news:ul**************@TK2MSFTNGP15.phx.gbl...I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
Thats a really neat way of doing it using SQL Server.
Very impressive.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi,
If you are getting the data from a sql server 2005 database you can use the row_number() over (order by colA) to create the ordinal. Here is a simple example.
Dim strConn As String Dim da As SqlDataAdapter Dim conn As SqlConnection Dim ds As New DataSet strConn = "Server = (local)\SQLEXPRESS;" strConn &= "Database = NorthWind; Integrated Security = SSPI;" conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select Row_Number() Over(Order by CustomerID) as MyOrdinal, * From Customers", conn) da.Fill(ds, "Customers")
DataGridView1.DataSource = ds.Tables("Customers")
Ken ---------------------------------------- "Wayne Wengert" <wa***********@wengert.org> wrote in message news:ul**************@TK2MSFTNGP15.phx.gbl...I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
Well, in a list of items, the key is the reference and the value is what is
assigned to it, basically I am talking about a value/pair list.
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Thanks for the response. I am not sure exactly what you are suggesting here? In the pseudo code, what is "key" in "If list contains key.."
Wayne
"Mr Newbie" <he**@now.com> wrote in message news:uQ**************@TK2MSFTNGP14.phx.gbl... Perhaps a list would do what you need. Each list item would contain a value ( countValue ), this way you could do something like
PSEUDO CODE For Each Value in your collection If List contains key, then Add 1 to value else create new Item with value of 1 End Loop
Bubble Sort List. "Wayne Wengert" <wa***********@wengert.org> wrote in message news:ul**************@TK2MSFTNGP15.phx.gbl...I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
> I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
You get part way there using Array.Sort with a tag-along vector:
Dim a() As Double = {6.6, 6.5, 6.2, 6.6, 6.7}
Dim n As Integer = UBound(a)
Dim r(n) As Integer
Dim i As Integer
For i = 0 To n : r(i) = i : Next
Array.Sort(a, r) ' sort a() ascending and tag along r()
Dim ord(n) As Integer
' below, n-i for descending vice ascending,
' and +1 for numbering starting at 1 vice 0
For i = 0 To n : ord(r(i)) = n - i + 1 : Next ' 2,4,5,3,1
If you want 2,4,5,2,1 vice 2,4,5,3,1, then some work remains where there
were ties in the data (6.6 in your example).
Thanks Ken;
I am not using SQL server in this case but that is a very neat approach.
I'll have to experiment with it.
Wayne
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hi,
If you are getting the data from a sql server 2005 database you can use the row_number() over (order by colA) to create the ordinal. Here is a simple example.
Dim strConn As String Dim da As SqlDataAdapter Dim conn As SqlConnection Dim ds As New DataSet strConn = "Server = (local)\SQLEXPRESS;" strConn &= "Database = NorthWind; Integrated Security = SSPI;" conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select Row_Number() Over(Order by CustomerID) as MyOrdinal, * From Customers", conn) da.Fill(ds, "Customers")
DataGridView1.DataSource = ds.Tables("Customers")
Ken ---------------------------------------- "Wayne Wengert" <wa***********@wengert.org> wrote in message news:ul**************@TK2MSFTNGP15.phx.gbl...I have a VB VSE 2005 project in which I need to rank about 35 columns of numbers. I want to end up with a dataset of ordinals. For example, if I have a dataset with 5 rows in which colA values are 6.6, 6.5, 6.2, 6.6, 6.7 respectively, the resulting ordinals would be 2, 4, 5, 2, 1.
I am currntly doing this in a brute force way. I put the values in an array and then walk through each column to calculate the ordinal and place it in a second array. When I have all the ordinals I put the array data into a dataset (I need a dataset to pass to the reporting code). Is there a better way to accomplish this?
TIA
Wayne
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt |
last post by:
Hello,
I'm a hiring C++ developer employer looking for existing, online C++
aptitude tests.
I have not yet extensively researched this yet, but as an example, I
thought this test looked...
|
by: JayCallas |
last post by:
This is more a theoretical question so I do not have any DDL (working)
to post.
Let's say that I have a query which needs to be filtered for specific
accounts while also needing several joins to...
|
by: JJ |
last post by:
Hi all,
Im looking for a better way to handle the exeption if you try to find a
node that doesnt exists?
It usualy breaks in a object exeption.
Now i have to use the try en catch option..
...
|
by: LDD |
last post by:
I'm looking for a good resource that explains all that is related to
datasets, datagrid, datatable, gridview, etc...
Anything related to loading and display db contents
LDD
|
by: Alan Silver |
last post by:
Hello,
MSDN (amongst other places) is full of helpful advice on ways to do data
access, but they all seem geared to wards enterprise applications. Maybe
I'm in a minority, but I don't have those...
|
by: dba123 |
last post by:
I am looking for a very good Enterprise Forum with Blog. This will be used
for our public website which serves about 1.5 million users.
This software cannot be cheesy, and must be as flexible as...
|
by: crystalattice |
last post by:
I've been working on a game for several months but now I'm thinking I
may be going about it the wrong way. It's an online RPG designed to
recreate a pen & paper session, kind of like the OpenRPG...
|
by: Matt England |
last post by:
I am looking for a C++ code beautifier/styler. Requirements and a
list of potential choices follow. I'm looking for people's specific
recommendations and reasons thereof per their specific...
|
by: BG Mahesh |
last post by:
hi
We are looking for a good Ajax library which has very good support for
iframe. The ones we have considered so far are,
Backbase.com - not happy with the speed
Zapatech.com - it is good but...
|
by: AMDRIT |
last post by:
I am looking for better concrete examples, as I am a bit dense, on design
patterns that facilitate my goals. I have been out to the code project,
planet source code, and microsoft's patterns and...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |