-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathart_foto_voting.sql
More file actions
31 lines (26 loc) · 909 Bytes
/
art_foto_voting.sql
File metadata and controls
31 lines (26 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
SELECT DISTINCT
COALESCE(
REPLACE(REPLACE(sub_nom, 'Традиционный ', ''), 'Digital ', ''),
list.title
) AS nom,
card_code AS nom_code,
[number] AS '№',
'=HYPERLINK("https://tulafest.cosplay2.ru/cards/card/'||requests.id||'"; "'||REPLACE(IFNULL(voting_title,'[Заявка без названия]'),'"',"'")||'")' AS "Заявка"
FROM requests, list, [values]
LEFT JOIN (
SELECT request_id AS sn_rid, value AS sub_nom
FROM [values]
WHERE title = 'Номинация'
) ON sn_rid = request_id
LEFT JOIN (
SELECT request_id AS comp_rid, value AS competition
FROM [values]
WHERE title = 'Участие в конкурсе'
) ON comp_rid = request_id
WHERE topic_id = list.id AND
request_id = requests.id AND
card_code in ('ART', 'FC', 'V', 'VC') AND
[status] = 'approved' AND
competition = 'В конкурсе'
--order by list.title, voting_title
ORDER BY nom