LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching 2D array for duplicates

Hi There. I wonder if someone can help.

 

I have a 2D array of strings (resulting from a database query) One col is a list of job numbers and the other is a list of dates. My SQL query produces results for distinct job numbers and distinct dates. So if there are entries in the database where a job number is split between two or more dates, there will be two (or more) entries.

 

SELECT DISTINCT SONumber, DateEstimatedShip FROM JobDetails WHERE jobdetails.status <700

 

What I am trying to do is search through the list of job numbers and list out in a separate array the numbers that are duplicated. I've tried to do this by passing the raw 2D array into a indexing tunnel in a for loop. Then check if there are any duplicates from the next position down in the array to the end. This works fine, but if there are any items that are duplicated more than once I get two entries in my list of duplicates - as in my example below job number 3466 is listed twice as it has three entries in the raw sql table.

 

How can I turn this array into a list of just the numbers that are duplicated (with no duplicates within it)

 

I hope I've explained this to a satisfactory level.

 

Any thoughts will be greatly appreciated.

array fp.JPG

array bd.JPG

0 Kudos
Message 1 of 5
(3,897 Views)

One approach would be to search the "list of duplicates" for new duplicates and delete them (remember to search until the index of the Search 1D Array function returns -1) or you do not insert the item into the list if it is already present (again, search the list but this time within your loop).

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(3,881 Views)

You can perform a second search on your 'list of duplicates' array using the same input as your first search, then if the second search index is <0 you can insert into the 'list of duplicates' array.

 

(Norbert beat me by a few seconds...)

Message Edited by Phillip Brooks on 12-02-2009 07:58 AM

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 3 of 5
(3,880 Views)

You should be able to modify your query to remove the duplicates, e.g.:

SELECT DISTINCT SONumber, DateEstimatedShip FROM JobDetails WHERE jobdetails.status <700 group by SONumber, DateEstimatedShip

 

/Y

Message Edited by Yamaeda on 12-02-2009 03:02 PM
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 5
(3,859 Views)

Hi fellas,

 

If you have not already seen it, here is a potencially useful forum link.

 

Reversing a 2D array by Row and removing duplicates

 

Best wishes,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 5 of 5
(3,829 Views)