summaryrefslogtreecommitdiff
path: root/doc/sql.txt
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-11-12 22:30:15 +0100
committeremkael <emkael@tlen.pl>2014-11-12 22:30:15 +0100
commitbb5a124f0138b8688b66d28dac88ea5007b9d6ab (patch)
tree89520d9ad69228558447495a16c91a7cfd3aa8ba /doc/sql.txt
parentc4bb1bd38d66e5df42863aac1bc5d7639f46c20f (diff)
* markdownization of documentation
Diffstat (limited to 'doc/sql.txt')
-rw-r--r--doc/sql.txt59
1 files changed, 0 insertions, 59 deletions
diff --git a/doc/sql.txt b/doc/sql.txt
deleted file mode 100644
index a21b607..0000000
--- a/doc/sql.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-Useful queries:
-
- - overall top rating progression
-
-CREATE OR REPLACE VIEW max_date_rankings AS
- SELECT MAX(ranking) max_ranking,
- rank_date max_rank_date
- FROM rankings
- GROUP BY rank_date;
-SELECT drivers.driver,
- max_date_rankings.max_rank_date,
- max_date_rankings.max_ranking
-FROM max_date_rankings
-INNER JOIN rankings ON (rankings.ranking = max_date_rankings.max_ranking)
- AND (rankings.rank_date = max_date_rankings.max_rank_date)
-LEFT JOIN drivers ON rankings._driver = drivers.id
-WHERE max_ranking > (
- SELECT MAX(mr.max_ranking) FROM max_date_rankings mr
- WHERE mr.max_rank_date < max_date_rankings.max_rank_date
-);
-
- - overall top peak ratings
-
-SELECT drivers.driver,
- rankings.ranking,
- rankings.rank_date
-FROM rankings
-INNER JOIN (
- SELECT MAX(ranking) ranking, _driver FROM rankings
- GROUP BY _driver
-) r ON r.ranking=rankings.ranking AND r._driver=rankings._driver
-JOIN drivers ON rankings._driver = drivers.id
-GROUP BY rankings._driver
-ORDER BY rankings.ranking DESC;
-
- - highest exit ratings
-
-SELECT drivers.driver,
- rankings.ranking,
- rankings.rank_date
-FROM rankings
-INNER JOIN (
- SELECT MAX(rank_date) rank_date, _driver FROM rankings GROUP BY _driver
-) r ON r.rank_date=rankings.rank_date AND r._driver=rankings._driver
-JOIN drivers ON rankings._driver = drivers.id
-WHERE rankings.rank_date < CURDATE() - INTERVAL 1 YEAR
-ORDER BY rankings.ranking DESC;
-
- - year-by-year rating inflation
-
-SELECT YEAR(rank_date),
- MAX(ranking),
- MIN(ranking),
- AVG(ranking),
- AVG(ranking)+STDDEV(ranking),
- AVG(ranking)-STDDEV(ranking)
-FROM rankings
-GROUP BY YEAR(rank_date)
-ORDER BY YEAR(rank_date) ASC;