November 6, 2007 at 11:00 am
This code does not give me a random order of numbers. It just gives me them in numerical order. Albeit 10,000 times.
November 6, 2007 at 11:57 am
Mark Green (11/6/2007)
This code does not give me a random order of numbers. It just gives me them in numerical order. Albeit 10,000 times.
I'm not sure we're using the table in the same way. Mine (and I think John's as well) uses the fields this way:
Generation_number = the generation
entry_key = the region to process
place_key = the order (within the generation) in which to "process" the generation.
So -
Select generation_number, place_key, entry_key from Random_region_lookup_table
order by generation_number, place_key
should give you a different ordering of the entry_keys (regions) for every generation.
Sorry - I was wondering if we were using the same fields in the same way.....Let me know how far off we are from what you need.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
November 7, 2007 at 1:34 am
Matt Miller (11/6/2007)
Mark Green (11/6/2007)
This code does not give me a random order of numbers. It just gives me them in numerical order. Albeit 10,000 times.I'm not sure we're using the table in the same way. Mine (and I think John's as well) uses the fields this way:
Generation_number = the generation
entry_key = the region to process
place_key = the order (within the generation) in which to "process" the generation.
Actually, I think mine was a little different. Entry_key was a unique row identifier, generation_number is the generation number (between 1 and 10000) and place_key was the order within the generation. This was why I said you needed to add another column for the name of the region (when you do it my way). Mark, even if this isn't exactly what you asked for, you should be able to tweak it to fit your exact requirements?
John
November 7, 2007 at 2:14 am
SELECT *
FROM my_table
ORDER BY RAND()
I think that I need to look for a solution that uses the RAND function. But that raises the question whether RAND is really RAND
November 7, 2007 at 6:25 am
The answer is, no... Within a given SELECT, Rand is not RAND unless it has a random seed... the only thing in SQL Server that even comes close to being random is NEWID()... and it's very random...
So, this will work just exactly like you'd like it to...
SELECT *
FROM my_table
ORDER BY NEWID()
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply