Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27897

Re: Computing win/loss records in Python

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.047
X-Spam-Evidence '*H*': 0.91; '*S*': 0.01; 'subject:Python': 0.05; 'practice,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'aug': 0.13; 'sat,': 0.15; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:loss': 0.16; 'integer': 0.17; 'select': 0.26; 'raw': 0.27; 'header:X-Complaints-To:1': 0.28; 'subject:/': 0.28; 'key,': 0.29; 'primary': 0.30; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'front': 0.33; 'skip:k 20': 0.35; 'table': 0.35; 'received:org': 0.36; 'charset :us-ascii': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'to,': 0.65; 'results': 0.65; 'date,': 0.65; 'records': 0.68; 'foreign': 0.72; 'score': 0.75; 'winner': 0.78; 'ohio': 0.84; 'played': 0.84; 'dennis': 0.91; 'subject:records': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Computing win/loss records in Python
Date Sat, 25 Aug 2012 23:13:20 -0400
Organization > Bestiaria Support Staff <
References <0C181E0E-47FA-439C-8320-AC60AB8859AF@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-253-111-70.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3825.1345950818.4697.python-list@python.org> (permalink)
Lines 68
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1345950818 news.xs4all.nl 6886 [2001:888:2000:d::a6]:55440
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:27897

Show key headers only | View raw


On Sat, 25 Aug 2012 22:20:05 -0400, Christopher McComas
<mccomas.chris@gmail.com> declaimed the following in
gmane.comp.python.general:

> Marshall
> Ohio State
> Kentucky
> Indiana

	Untested pseudo SQL

create table Teams
(
	ID	integer auto-increment primary key,
	name	char(?)
)
 
> Marshall,24,Ohio State,48,
> Kentucky,14,Indiana,10,
> Marshall,10,Indiana,7,
> Ohio State,28,Kentucky,10

create table Game
(
	ID	integer auto-increment primary key,
	gameDate	date
)

create table GameScore
(
	ID	integer auto-increment primary key,
	gameID	integer foreign key Game(ID),
	teamID		integer foreign key Team(ID),
	score		integer
)

{wins}
select t.name, cnt(t.name) from GameScore as gs
inner join Team as t
on t.ID = gs.teamID
inner join GameScore as gs2
on gs.gameID = gs2.gameID
group by t.name
having gs.score > gs2.score

{I'm out of practice, so the constraints on group by/having may not be
valid}

{losses}
...
having gs.score < gs2.score

{ties/draws}
...
having gs.score = gs2.score
 
	GameScore avoids having to explicitlly order the raw results to, for
example, always put the winner in front as in

ID, date, winningTeamID, winningScore, losingTeamID, losingScore

{to get the number of games a team played in would require obtaining the
count of records with the team ID in winningTeamID and adding the count
of records with the same team ID in losingTeamID}
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Computing win/loss records in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-25 23:13 -0400

csiph-web