2019-08-08 14:20:25 +00:00
|
|
|
set any_join_distinct_right_table_keys = 1;
|
2019-08-06 14:29:49 +00:00
|
|
|
|
2018-08-07 17:08:51 +00:00
|
|
|
SELECT
|
|
|
|
CounterID,
|
|
|
|
hits,
|
|
|
|
visits
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
count() AS hits
|
|
|
|
FROM test.hits
|
|
|
|
GROUP BY CounterID
|
|
|
|
) ANY FULL OUTER JOIN
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
sum(Sign) AS visits
|
|
|
|
FROM test.visits
|
|
|
|
GROUP BY CounterID
|
|
|
|
HAVING visits > 0
|
|
|
|
) USING CounterID
|
|
|
|
WHERE hits = 0 OR visits = 0
|
|
|
|
ORDER BY
|
|
|
|
hits + visits * 10 DESC,
|
|
|
|
CounterID ASC
|
|
|
|
LIMIT 20;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
CounterID,
|
|
|
|
hits,
|
|
|
|
visits
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
count() AS hits
|
|
|
|
FROM test.hits
|
|
|
|
GROUP BY CounterID
|
|
|
|
) ANY LEFT JOIN
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
sum(Sign) AS visits
|
|
|
|
FROM test.visits
|
|
|
|
GROUP BY CounterID
|
|
|
|
HAVING visits > 0
|
|
|
|
) USING CounterID
|
|
|
|
WHERE hits = 0 OR visits = 0
|
|
|
|
ORDER BY
|
|
|
|
hits + visits * 10 DESC,
|
|
|
|
CounterID ASC
|
|
|
|
LIMIT 20;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
CounterID,
|
|
|
|
hits,
|
|
|
|
visits
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
count() AS hits
|
|
|
|
FROM test.hits
|
|
|
|
GROUP BY CounterID
|
|
|
|
) ANY RIGHT JOIN
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
sum(Sign) AS visits
|
|
|
|
FROM test.visits
|
|
|
|
GROUP BY CounterID
|
|
|
|
HAVING visits > 0
|
|
|
|
) USING CounterID
|
|
|
|
WHERE hits = 0 OR visits = 0
|
|
|
|
ORDER BY
|
|
|
|
hits + visits * 10 DESC,
|
|
|
|
CounterID ASC
|
|
|
|
LIMIT 20;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
CounterID,
|
|
|
|
hits,
|
|
|
|
visits
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
count() AS hits
|
|
|
|
FROM test.hits
|
|
|
|
GROUP BY CounterID
|
|
|
|
) ANY INNER JOIN
|
|
|
|
(
|
|
|
|
SELECT
|
2018-12-29 22:11:00 +00:00
|
|
|
(CounterID % 100000) AS CounterID,
|
2018-08-07 17:08:51 +00:00
|
|
|
sum(Sign) AS visits
|
|
|
|
FROM test.visits
|
|
|
|
GROUP BY CounterID
|
|
|
|
HAVING visits > 0
|
|
|
|
) USING CounterID
|
|
|
|
WHERE hits = 0 OR visits = 0
|
|
|
|
ORDER BY
|
|
|
|
hits + visits * 10 DESC,
|
|
|
|
CounterID ASC
|
|
|
|
LIMIT 20;
|