
December 29th, 2006, 07:35 PM
| | | creating random teams?
het gang. Happy Holidays and stuff.
Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.
using sql db on ms server
i have players sign up for a tourney. easy
when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =
now, i need to script to count the number registered.. easy
then set by dividing by the preset variable will tell how many teams there
will be..
so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.
now i need to assign by a random script, who is on what team, so that 3
people are on each team.
i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.
so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?
does this make sense of what i want?/
any help would be appreciated.
Bam | 
December 29th, 2006, 07:35 PM
| | | Re: creating random teams?
"Jeff" <gig_bam@adelphia.netwrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com ... Quote:
het gang. Happy Holidays and stuff.
>
Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.
>
using sql db on ms server
>
i have players sign up for a tourney. easy
>
when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =
>
now, i need to script to count the number registered.. easy
>
then set by dividing by the preset variable will tell how many teams there
will be..
>
so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.
>
now i need to assign by a random script, who is on what team, so that 3
people are on each team.
>
i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.
>
so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?
>
does this make sense of what i want?/
>
any help would be appreciated.
>
Bam
>
| I should add that the name field is t_username, in case that is needed in
the help | 
December 29th, 2006, 07:45 PM
| | | Re: creating random teams?
"Jeff" <gig_bam@adelphia.netwrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com ... Quote:
het gang. Happy Holidays and stuff.
>
Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.
>
using sql db on ms server
>
i have players sign up for a tourney. easy
>
when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =
>
now, i need to script to count the number registered.. easy
>
then set by dividing by the preset variable will tell how many teams there
will be..
>
so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.
>
now i need to assign by a random script, who is on what team, so that 3
people are on each team.
>
i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.
>
so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?
>
does this make sense of what i want?/
>
any help would be appreciated.
>
Bam
>
| An alternative might be to sort the players by, say,
the second character in their last name and then use
three at a time to make a team. | 
December 29th, 2006, 07:45 PM
| | | Re: creating random teams?
"McKirahan" <News@McKirahan.comwrote in message
news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com. .. Quote:
"Jeff" <gig_bam@adelphia.netwrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com ... Quote:
>het gang. Happy Holidays and stuff.
>>
>Here is what I am wanting to do, but need some guidance as hwo to start
>in
>the right direction.
>>
>using sql db on ms server
>>
>i have players sign up for a tourney. easy
>>
>when the tourney begins, i want it to set teams. i have a number in the
>db
>that tells how many on a team. ivarnum =
>>
>now, i need to script to count the number registered.. easy
>>
>then set by dividing by the preset variable will tell how many teams
>there
>will be..
>>
>so say 21 players registered, and the ivarnum = 3, thus giving that there
>will be 7 teams.
>>
>now i need to assign by a random script, who is on what team, so that 3
>people are on each team.
>>
>i have a field in the db called t_team, this is an integer, so it will
>get
>assigned a number 1-7, and that will be taht persons team for the
>tourney.
>>
>so how can i assign this random number between 1 and 7 (in this case) and
>once 3 are choosen with the same number, it won't use it again?
>>
>does this make sense of what i want?/
>>
>any help would be appreciated.
>>
>Bam
>>
| >
An alternative might be to sort the players by, say,
the second character in their last name and then use
three at a time to make a team.
>
>
| now that's a thought. I was also thinking about getting every 3rd entry, and
when it gets to eof, going back and doing it again with those who have a
t_team of 0 | 
December 29th, 2006, 08:05 PM
| | | Re: creating random teams?
"Jeff" <gig_bam@adelphia.netwrote in message
news:iuSdndu4Q9tg8wjYnZ2dnUVZ_oannZ2d@adelphia.com ... Quote:
>
"McKirahan" <News@McKirahan.comwrote in message
news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com. .. Quote:
>"Jeff" <gig_bam@adelphia.netwrote in message
>news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.co m... Quote:
>>het gang. Happy Holidays and stuff.
>>>
>>Here is what I am wanting to do, but need some guidance as hwo to start
>>in
>>the right direction.
>>>
>>using sql db on ms server
>>>
>>i have players sign up for a tourney. easy
>>>
>>when the tourney begins, i want it to set teams. i have a number in the
>>db
>>that tells how many on a team. ivarnum =
>>>
>>now, i need to script to count the number registered.. easy
>>>
>>then set by dividing by the preset variable will tell how many teams
>>there
>>will be..
>>>
>>so say 21 players registered, and the ivarnum = 3, thus giving that
>>there
>>will be 7 teams.
>>>
>>now i need to assign by a random script, who is on what team, so that 3
>>people are on each team.
>>>
>>i have a field in the db called t_team, this is an integer, so it will
>>get
>>assigned a number 1-7, and that will be taht persons team for the
>>tourney.
>>>
>>so how can i assign this random number between 1 and 7 (in this case)
>>and
>>once 3 are choosen with the same number, it won't use it again?
>>>
>>does this make sense of what i want?/
>>>
>>any help would be appreciated.
>>>
>>Bam
>>>
| >>
>An alternative might be to sort the players by, say,
>the second character in their last name and then use
>three at a time to make a team.
>>
>>
| now that's a thought. I was also thinking about getting every 3rd entry,
and when it gets to eof, going back and doing it again with those who have
a t_team of 0
| Forget your idea. Use McKirahan's. Using the card game solitaire as an
analogy, McKirahan will finish his game by going through the deck of cards
once. You will go through the card deck seven times to accomplish the same
thing. In other words, you will be creating seven recordsets, whereas
McKirahan's approach requires just one.
--
Mike Brind | 
December 29th, 2006, 08:25 PM
| | | Re: creating random teams?
"McKirahan" <News@McKirahan.comwrote in message
news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com. .. Quote:
"Jeff" <gig_bam@adelphia.netwrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com ... Quote:
>het gang. Happy Holidays and stuff.
>>
>Here is what I am wanting to do, but need some guidance as hwo to start
>in
>the right direction.
>>
>using sql db on ms server
>>
>i have players sign up for a tourney. easy
>>
>when the tourney begins, i want it to set teams. i have a number in the
>db
>that tells how many on a team. ivarnum =
>>
>now, i need to script to count the number registered.. easy
>>
>then set by dividing by the preset variable will tell how many teams
>there
>will be..
>>
>so say 21 players registered, and the ivarnum = 3, thus giving that there
>will be 7 teams.
>>
>now i need to assign by a random script, who is on what team, so that 3
>people are on each team.
>>
>i have a field in the db called t_team, this is an integer, so it will
>get
>assigned a number 1-7, and that will be taht persons team for the
>tourney.
>>
>so how can i assign this random number between 1 and 7 (in this case) and
>once 3 are choosen with the same number, it won't use it again?
>>
>does this make sense of what i want?/
>>
>any help would be appreciated.
>>
>Bam
>>
| >
An alternative might be to sort the players by, say,
the second character in their last name and then use
three at a time to make a team.
>
>
| roger that. i see where you are going with this.
so i could create a case then. and depending on how many teams there will
be, is how many it will grab from the sort??
is that what i am understanding here?? | 
December 29th, 2006, 08:25 PM
| | | Re: creating random teams?
Jeff wrote: Quote:
...using sql db on ms server...
>
...now i need to assign by a random script, who is on what team,
so that 3 people are on each team...
| In SQL Server, you can always randomize any recordset with this clause:
ORDER BY NEWID()
So, select all players with that clause and assign the first three to team
1, the next three to team 2, and so on.
SELECT * FROM [your table of registrants]
ORDER BY NEWID()
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. | 
December 29th, 2006, 08:35 PM
| | | Re: creating random teams?
"Dave Anderson" <NYRUMTPELVWH@spammotel.comwrote in message
news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl... Quote:
Jeff wrote: Quote:
>...using sql db on ms server...
>>
>...now i need to assign by a random script, who is on what team,
>so that 3 people are on each team...
| >
In SQL Server, you can always randomize any recordset with this clause:
>
ORDER BY NEWID()
>
So, select all players with that clause and assign the first three to team
1, the next three to team 2, and so on.
>
SELECT * FROM [your table of registrants]
ORDER BY NEWID()
>
>
>
--
Dave Anderson
>
Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms.
>
| but using that, it would set the teams by the order they signed up?? | 
December 30th, 2006, 08:35 PM
| | | Re: creating random teams?
Gazing into my crystal ball I observed "Jeff" <gig_bam@adelphia.net>
writing in news:U7CdndxuAbCY5wjYnZ2dnUVZ_rOqnZ2d@adelphia.com : Quote:
>
"Dave Anderson" <NYRUMTPELVWH@spammotel.comwrote in message
news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl... Quote:
>Jeff wrote: Quote:
>>...using sql db on ms server...
>>>
>>...now i need to assign by a random script, who is on what team,
>>so that 3 people are on each team...
| >>
>In SQL Server, you can always randomize any recordset with this
>clause:
>>
> ORDER BY NEWID()
>>
>So, select all players with that clause and assign the first three to
>team 1, the next three to team 2, and so on.
>>
> SELECT * FROM [your table of registrants]
> ORDER BY NEWID()
>>
| but using that, it would set the teams by the order they signed up??
>
| No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4, 2,
9 etc.
--
Adrienne Boswell at Home
Arbpen Web Site Design Services http://www.cavalcade-of-coding.info
Please respond to the group so others can share | 
January 1st, 2007, 03:05 PM
| | | Re: creating random teams?
"Adrienne Boswell" <arbpen@yahoo.comwrote in message
news:Xns98A97EE3469A2arbpenyahoocom@69.28.186.121. .. Quote:
Gazing into my crystal ball I observed "Jeff" <gig_bam@adelphia.net>
writing in news:U7CdndxuAbCY5wjYnZ2dnUVZ_rOqnZ2d@adelphia.com :
> Quote:
>>
>"Dave Anderson" <NYRUMTPELVWH@spammotel.comwrote in message
>news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl... Quote:
>>Jeff wrote:
>>>...using sql db on ms server...
>>>>
>>>...now i need to assign by a random script, who is on what team,
>>>so that 3 people are on each team...
>>>
>>In SQL Server, you can always randomize any recordset with this
>>clause:
>>>
>> ORDER BY NEWID()
>>>
>>So, select all players with that clause and assign the first three to
>>team 1, the next three to team 2, and so on.
>>>
>> SELECT * FROM [your table of registrants]
>> ORDER BY NEWID()
>>>
| >but using that, it would set the teams by the order they signed up??
>>
| >
No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4, 2,
9 etc.
>
>
--
Adrienne Boswell at Home
Arbpen Web Site Design Services http://www.cavalcade-of-coding.info
Please respond to the group so others can share
>
| Ok, I understand that.
Now, if there are say... 48 members, would I write a case to determine how
many teams to create?
because the number of teams would probably change each time the script is
run.
sorry for my ignorance, but something things take a little longer to pound
in. | 
January 1st, 2007, 03:55 PM
| | | Re: creating random teams?
Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general: Quote: Quote:
>No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4,
>2, 9 etc.
| >
Ok, I understand that.
Now, if there are say... 48 members, would I write a case to determine
how many teams to create?
>
because the number of teams would probably change each time the script
is run.
>
sorry for my ignorance, but something things take a little longer to
pound in.
| Simply fill team 1 with the first 3 members from the random db results,
team 2 with the second 3 members,
etc.
You will end up with a number of teams.
The last team could have less than 3 members.
What you do with those members is up to your definition.
[48 members will fill exactly 16 teams.]
Just straightforward programming, meseems.
You could give each member an extra field in his record,
named 'teamNumberMatchJan2007'.
[and build and maintain other teams in other matchesand keep those on
record at the same time]
VBS-ish pseudocode:
..........
ORDER BY NEWID()
n=1 ' counter
t=1 ' teamcounter
do until end of table
field["teamNumberMatchJan2007"] = t
n = n + 1
if n 3 then n = 1 : t = t + 1
nextRecord
loop
you could then, if you like, give the team members [5 here] personal
points based on their team [number 12 here] performance:
UPDATE membTbl
SET points = points + 5
WHERE teamNumberMatchJan2007 = 12
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) | 
January 1st, 2007, 04:55 PM
| | | Re: creating random teams?
thanks for that.
i got it to work thanks to you all
Happy New Year!!
"Evertjan." <exjxw.hannivoort@interxnl.netwrote in message
news:Xns98ABABB99970Aeejj99@194.109.133.242... Quote:
Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general:
> Quote: Quote:
>>No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4,
>>2, 9 etc.
| >>
>Ok, I understand that.
>Now, if there are say... 48 members, would I write a case to determine
>how many teams to create?
>>
>because the number of teams would probably change each time the script
>is run.
>>
>sorry for my ignorance, but something things take a little longer to
>pound in.
| >
Simply fill team 1 with the first 3 members from the random db results,
team 2 with the second 3 members,
etc.
>
You will end up with a number of teams.
The last team could have less than 3 members.
What you do with those members is up to your definition.
>
[48 members will fill exactly 16 teams.]
>
Just straightforward programming, meseems.
>
You could give each member an extra field in his record,
named 'teamNumberMatchJan2007'.
[and build and maintain other teams in other matchesand keep those on
record at the same time]
>
VBS-ish pseudocode:
>
.........
ORDER BY NEWID()
>
n=1 ' counter
t=1 ' teamcounter
do until end of table
field["teamNumberMatchJan2007"] = t
n = n + 1
if n 3 then n = 1 : t = t + 1
nextRecord
loop
>
you could then, if you like, give the team members [5 here] personal
points based on their team [number 12 here] performance:
>
UPDATE membTbl
SET points = points + 5
WHERE teamNumberMatchJan2007 = 12
>
>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|