We have a table with a list of advert campaigns, each campaign is assigned a percent value and the cumulative value will always add up to 100. Mixed in with this is a region, you can have a region of 'ALL' and different regions, 'GB', 'FR' etc..
The ALL region + the specific region must add up to no more than 100%, if it's under then we can use a default advert campaign.
For example, our table looks like this:
CampaignID int identity(1,1)
1, Example1, 'ALL', 70
2, Example2, 'GB', 30
3, Example3, 'FR', 20
So if you're in GB then ALL + GB add up to 100, if you're in france then FR + ALL = 90, the remaining 10% would be a generic campaign.
So, basically, i'm trying to run a function which will return a random campaignID based on the percentage chance of it coming out, but can't seem to work out the best way of doing it.
Thanks in advance.