41 lines
1.9 KiB
SQL
41 lines
1.9 KiB
SQL
WITH current_series AS (
|
|
SELECT
|
|
1 + COALESCE(c.shootout_extra_rounds, 0) AS series_number
|
|
FROM (SELECT CAST(:game_id AS text) AS game_id) p
|
|
LEFT JOIN hockey_game_control_states c
|
|
ON c.game_external_id = p.game_id
|
|
),
|
|
attempt_images AS (
|
|
SELECT
|
|
a.side,
|
|
CASE
|
|
WHEN s.series_number = 1 THEN a.team_attempt_number
|
|
ELSE 1
|
|
END AS slot,
|
|
CASE
|
|
WHEN a.scored IS TRUE
|
|
THEN 'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Green-01.png'
|
|
WHEN a.scored IS FALSE
|
|
THEN 'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Red-01.png'
|
|
ELSE 'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png'
|
|
END AS image_path
|
|
FROM hockey_shootout_attempts a
|
|
CROSS JOIN current_series s
|
|
WHERE a.game_external_id = :game_id
|
|
AND a.series_number = s.series_number
|
|
)
|
|
SELECT
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'home' AND slot = 1),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic1,
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'home' AND slot = 2),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic2,
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'home' AND slot = 3),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic3,
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'away' AND slot = 1),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic4,
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'away' AND slot = 2),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic5,
|
|
COALESCE(MAX(image_path) FILTER (WHERE side = 'away' AND slot = 3),
|
|
'D:\Графика\ХОККЕЙ\KHL_26_27\Elements\Shootout\Line-01.png') AS pic6
|
|
FROM attempt_images;
|