]> git.sesse.net Git - ccbs/blob - sql/fixup-chosensongs.sql
Specify join, so that we don't join tournament+score on country. :-)
[ccbs] / sql / fixup-chosensongs.sql
1 --
2 -- Fix some brokenness in the data we get from DDR Europe; specifically,
3 -- if all players in a round select the same chosen song, the data says
4 -- that is was a random song. We find the most obvious cases and fix them;
5 -- I don't believe there are any more of them than those.
6 --
7
8 BEGIN;
9
10 UPDATE scores SET chosen='t' WHERE (tournament,round,songnumber) IN (
11         SELECT tournament,round,randomsongs-1 FROM rounds WHERE chosensongs = 0 AND randomsongs > 1
12 );
13
14 UPDATE rounds SET chosensongs=1,randomsongs=randomsongs-1 WHERE (tournament,round) IN (
15         SELECT tournament, round FROM rounds WHERE chosensongs = 0 AND randomsongs > 1
16 );
17
18 COMMIT;
19