I have a question about a select statement. Currently I have a select statement that does what I want it to do, but it needs to be altered, giving my WHERE options an equal chance to show.
SELECT TOP 1 *, NEWID() as Random
WHERE CODE = 'AB' OR CODE = 'ABC'
ORDER BY Random
It seems to work pretty well for the purpose. Often I will need 3 to 6 different Code types. What I need it to do is give each CODE type an equal oportunity to display.
I have WHERE CODE = 'AB' OR CODE = 'ABC' OR CODE = 'ABCD'
I'd like them to, in this instance, have a 33% to show. More or less, I'd like, 1 of AB, ABC, ABCD, then I want them to randomize agian.
If I have 4 Code types, I'd like a Select statement to grab 1 of each, and give them a 25% chance to show, by randomizing those 4.
View Complete Post