SQL
- 10 ответов
- 0 вопросов
4
Вклад в тег
((X + 1) % 5) * ((X + 2) % 5) * ((X + 3) % 5) * ((X + 4) % 5)
(((X + 1) % 5) * ((X + 2) % 5) * ((X + 3) % 5) * ((X + 4) % 5) +
((Y + 1) % 5) * ((Y + 2) % 5) * ((Y + 3) % 5) * ((Y + 4) % 5) +
((Z + 1) % 5) * ((Z + 2) % 5) * ((Z + 3) % 5) * ((Z + 4) % 5)
) == 24
SELECT id FROM x
UNION ALL
SELECT id FROM x
UNION ALL
SELECT x_id FROM y
SELECT id
FROM (SELECT id FROM x
UNION ALL
SELECT id FROM x
UNION ALL
SELECT x_id FROM y
)
GROUP BY id
HAVING COUNT(*) = 2
SELECT DISTINCT id FROM x
SELECT id FROM x
i [i / 3] 4 * (i % 3) index
0: 1 + 0 + 4 * 0 = 1
1: 1 + 0 + 4 * 1 = 5
2: 1 + 0 + 4 * 2 = 9
3: 1 + 1 + 4 * 0 = 2
4: 1 + 1 + 4 * 1 = 6
5: 1 + 1 + 4 * 2 = 10
6: 1 + 2 + 4 * 0 = 3
7: 1 + 2 + 4 * 1 = 7
...