|
1 | | -select SKIP @firstRowIndex@ FIRST @pageSize@ |
2 | | - r.round_id |
3 | | - ,r.short_name AS name |
4 | | - ,cal.date AS start_date |
5 | | - ,NVL(rd1.num_coders, 0) + NVL(rd2.num_coders, 0) AS total_competitors |
6 | | - ,rd1.num_coders AS div_i_competitors |
7 | | - ,rd2.num_coders AS div_ii_competitors |
8 | | - ,rd1.problems_submitted AS div_i_total_solutions_submitted |
9 | | - ,rd2.problems_submitted AS div_ii_total_solutions_submitted |
10 | | - ,CASE WHEN rd1.num_coders = 0 THEN 0 ELSE rd1.problems_submitted / rd1.num_coders END::DECIMAL(10,2) AS div_i_average_solutions_submitted |
11 | | - ,CASE WHEN rd2.num_coders = 0 THEN 0 ELSE rd2.problems_submitted / rd2.num_coders END::DECIMAL(10,2) AS div_ii_average_solutions_submitted |
12 | | - ,rd1.challenges_made_successful AS div_i_total_solutions_challenged |
13 | | - ,rd2.challenges_made_successful AS div_ii_total_solutions_challenged |
14 | | - ,CASE WHEN rd1.num_coders = 0 THEN 0 ELSE rd1.challenges_made_successful / rd1.num_coders END::DECIMAL(10,2) AS div_i_average_solutions_challenged |
15 | | - ,CASE WHEN rd2.num_coders = 0 THEN 0 ELSE rd2.challenges_made_successful / rd2.num_coders END::DECIMAL(10,2) AS div_ii_average_solutions_challenged |
16 | | - FROM contest c |
17 | | - JOIN round AS r ON r.contest_id = c.contest_id AND r.failed = 0 AND r.status='A' |
18 | | - LEFT JOIN round_division AS rd1 ON rd1.division_id = 1 AND rd1.round_id = r.round_id |
19 | | - LEFT JOIN round_division AS rd2 ON rd2.division_id = 2 AND rd2.round_id = r.round_id |
20 | | - JOIN calendar AS cal ON cal.calendar_id = r.calendar_id |
21 | | -WHERE r.round_type_id in (1, 2, 10) |
| 1 | +SELECT SKIP @firstRowIndex@ FIRST @pageSize@ |
| 2 | + r.round_id |
| 3 | +, r.name |
| 4 | +, rs.start_time AS start_date |
| 5 | +, NVL(rd1.div_i_competitors, 0) + NVL(rd2.div_ii_competitors, 0) AS total_competitors |
| 6 | +, rd1.div_i_competitors |
| 7 | +, rd2.div_ii_competitors |
| 8 | +, rd1.div_i_total_solutions_submitted |
| 9 | +, rd2.div_ii_total_solutions_submitted |
| 10 | +, CASE WHEN rd1.div_i_competitors = 0 THEN 0 ELSE rd1.div_i_total_solutions_submitted / rd1.div_i_competitors END::DECIMAL(10, 2) AS div_i_average_solutions_submitted |
| 11 | +, CASE WHEN rd2.div_ii_competitors = 0 THEN 0 ELSE rd2.div_ii_total_solutions_submitted / rd2.div_ii_competitors END::DECIMAL(10, 2) AS div_ii_average_solutions_submitted |
| 12 | +, rd1.div_i_total_solutions_challenged |
| 13 | +, rd2.div_ii_total_solutions_challenged |
| 14 | +, CASE WHEN rd1.div_i_competitors = 0 THEN 0 ELSE rd1.div_i_total_solutions_challenged / rd1.div_i_competitors END::DECIMAL(10, 2) AS div_i_average_solutions_challenged |
| 15 | +, CASE WHEN rd2.div_ii_competitors = 0 THEN 0 ELSE rd2.div_ii_total_solutions_challenged / rd2.div_ii_competitors END::DECIMAL(10, 2) AS div_ii_average_solutions_challenged |
| 16 | +FROM round r |
| 17 | +INNER JOIN round_segment rs ON rs.round_id = r.round_id AND rs.segment_id = 1 |
| 18 | +LEFT JOIN ( |
| 19 | + SELECT |
| 20 | + rr.round_id |
| 21 | + , COUNT(*) AS div_i_competitors |
| 22 | + , NVL((SELECT COUNT(*) FROM challenge c WHERE c.status_id <> 92 AND c.round_id = rr.round_id AND c.succeeded = 1), 0) AS div_i_total_solutions_challenged |
| 23 | + , NVL((SELECT SUM(CASE WHEN cs.status_id >= 130 THEN 1 ELSE 0 END) FROM component_state cs WHERE cs.round_id = rr.round_id), 0) AS div_i_total_solutions_submitted |
| 24 | + FROM room_result rr |
| 25 | + INNER JOIN room ON room.room_id = rr.room_id AND room.division_id = 1 |
| 26 | + GROUP BY rr.round_id |
| 27 | +) rd1 ON rd1.round_id = r.round_id |
| 28 | +LEFT JOIN ( |
| 29 | + SELECT |
| 30 | + rr.round_id |
| 31 | + , COUNT(*) AS div_ii_competitors |
| 32 | + , NVL((SELECT COUNT(*) FROM challenge c WHERE c.status_id <> 92 AND c.round_id = rr.round_id AND c.succeeded = 1), 0) AS div_ii_total_solutions_challenged |
| 33 | + , NVL((SELECT SUM(CASE WHEN cs.status_id >= 130 THEN 1 ELSE 0 END) FROM component_state cs WHERE cs.round_id = rr.round_id), 0) AS div_ii_total_solutions_submitted |
| 34 | + FROM room_result rr |
| 35 | + INNER JOIN room ON room.room_id = rr.room_id AND room.division_id = 2 |
| 36 | + GROUP BY rr.round_id |
| 37 | +) rd2 ON rd2.round_id = r.round_id |
| 38 | +WHERE r.status = '@status@' |
| 39 | +AND r.round_type_id IN (1, 2, 10) |
| 40 | + |
22 | 41 | ORDER BY @sortColumn@ @sortOrder@, round_id desc |
0 commit comments