Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Random Assignment of Employees to Locations

GmoneyJul 5 2017 — edited Aug 25 2017

Good day all,

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production

"CORE 11.2.0.1.0 Production"

TNS for 32-bit Windows: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

I will base this question of the HR Schema for simplicity.

I have two tables Employees and Locations. For this example, I have 37 locations and 173 employees.

My locations have a specific number assigned indicating the number of employees that need to be assigned to the location.

What I am attempting to do is randomly assign the number of required employees for each location from the employees table.

Thanks for looking at my issue.

As such an example of desired results would be:

 

EMPLOYEE_IDFIRST_NAMELAST_NAMESTREET_ADDRESSCITYSTATE
1ASmith737 Any RoadAnywhereUSA
2BJones50 Some RoadNowhereUSA
3CButler737 Any RoadAnywhereUSA
4DThomas50 Some RoadNowhereUSA
5EMarsh737 Any RoadAnywhereUSA
6FRuppert50 Some RoadNowhereUSA
7GGlenn50 Some RoadNowhereUSA

   

EMPLOYEE_IDFIRST_NAMELAST_NAME
000001ASmith
000002BJones
000003Cutler
000004DThomas
000005EMarsh
000006FRuppert
000007GGlenn

 

STRET_ADDRESSCITYHEAD_CNTSTATE
737 Any RoadAnywhere3USA
50 Some RoadNowhere4USA
This post has been answered by sdstuber on Jul 5 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2017
Added on Jul 5 2017
19 comments
1,169 views