SQL Question - Splitting populations

I have 2 separate populations in which I need to split each population randomly (50-50) and take the 50% from each population and combine them into a temp table.  

Example:

Population A:
1000 people

Population B:
2000 people

Need to spilt Population A 50-50(randomly) and take 50%(500 people) and insert them in Temp Table C.  Then take 50% from Population B(again this would be randomly split at 50-50) and insert that into Temp Table C as well.  So Temp Table C would have a total population of 1500...

Any ideas on this?

Fiqbal
fiqbalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ccarnsCommented:
Here is the start to your solution, this is not really random - but randomness depends on how the data was entered in the first place:

DECLARE @TABLE_A_COUNT int
DECLARE @TABLE_B_COUNT int

SET @TABLE_A_COUNT = COUNT(*)/2 FROM TABLE_A
SET @TABLE_B_COUNT = COUNT(*)/2 FROM TABLE_B

SELECT TOP @TABLE_A_COUNT Field1 FROM TABLE_A

UNION

SELECT TOP @TABLE_B_COUNT Field1 FROM TABLE_A
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ralf KlattEmployee in Civil ServiceCommented:
Hi,

I'd suggest this as solution:

select top 50 percent * into tempTable from YourTable1
union
select top 50 percent * from YourTable2
select * from tempTable


Best regards,
Raisor
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.