summaryrefslogtreecommitdiff
path: root/playoff/sql.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-02-22 14:25:36 +0100
committeremkael <emkael@tlen.pl>2017-02-22 14:25:36 +0100
commitf118c0f3704fa07a33543ee2aa018f16ac993b5a (patch)
treefba2537a34740a72875e3713c187adbbe52fc003 /playoff/sql.py
Initial commit
Diffstat (limited to 'playoff/sql.py')
-rw-r--r--playoff/sql.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/playoff/sql.py b/playoff/sql.py
new file mode 100644
index 0000000..0bd2df7
--- /dev/null
+++ b/playoff/sql.py
@@ -0,0 +1,23 @@
+MATCH_RESULTS = '''
+SELECT t1.fullname, t2.fullname, matches.carry, matches.vph, matches.vpv, matches.corrh, matches.corrv
+FROM #db#.matches matches
+JOIN #db#.teams t1
+ ON t1.id = #db#.matches.homet
+JOIN #db#.teams t2
+ ON t2.id = #db#.matches.visit
+WHERE matches.tabl = %s AND matches.rnd = %s
+'''
+
+BOARD_COUNT = '''
+SELECT segmentsperround*boardspersegment, SUM(sc1.contract IS NOT NULL AND sc2.contract IS NOT NULL)
+FROM #db#.scores sc1
+JOIN #db#.scores sc2
+ ON sc1.rnd = sc2.rnd
+ AND sc1.segment = sc2.segment
+ AND sc1.tabl = sc2.tabl
+ AND sc1.board = sc2.board
+ AND sc1.room = 1
+ AND sc2.room = 2
+JOIN #db#.admin
+WHERE sc1.tabl = %s AND sc1.rnd = %s
+'''