mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-05 23:31:24 +00:00
0324770773
sed -r -i \ -e 's/SELECT $/SELECT/' \ -e 's/SELECT DISTINCT $/SELECT DISTINCT/' \ -e 's/WITH $/WITH/' \ # zero matches, new test will be added -e 's/ARRAY JOIN $/ARRAY JOIN/' \ -e 's/GROUP BY $/GROUP BY/' \ -e 's/ORDER BY $/ORDER BY/' \ -e 's/LIMIT ([0-9]+) BY $/LIMIT \1 BY/' \ # zero matches, new test will be added tests/queries/*/*.sql \ tests/queries/*/*.reference (With except for tests/queries/0_stateless/00751_default_databasename_for_view.reference)
36 lines
1.1 KiB
SQL
36 lines
1.1 KiB
SQL
DROP TABLE IF EXISTS perf;
|
|
CREATE TABLE perf (site String, user_id UInt64, z Float64) ENGINE = Log;
|
|
|
|
SELECT * FROM (SELECT perf_1.z AS z_1 FROM perf AS perf_1);
|
|
|
|
SELECT sum(mul)/sqrt(sum(sqr_dif_1) * sum(sqr_dif_2)) AS z_r
|
|
FROM(
|
|
SELECT
|
|
(SELECT avg(z_1) AS z_1_avg,
|
|
avg(z_2) AS z_2_avg
|
|
FROM (
|
|
SELECT perf_1.site, perf_1.z AS z_1
|
|
FROM perf AS perf_1
|
|
WHERE user_id = 000
|
|
) jss1 ALL INNER JOIN (
|
|
SELECT perf_2.site, perf_2.z AS z_2
|
|
FROM perf AS perf_2
|
|
WHERE user_id = 999
|
|
) jss2 USING site) as avg_values,
|
|
z_1 - avg_values.1 AS dif_1,
|
|
z_2 - avg_values.2 AS dif_2,
|
|
dif_1 * dif_2 AS mul,
|
|
dif_1*dif_1 AS sqr_dif_1,
|
|
dif_2*dif_2 AS sqr_dif_2
|
|
FROM (
|
|
SELECT perf_1.site, perf_1.z AS z_1
|
|
FROM perf AS perf_1
|
|
WHERE user_id = 000
|
|
) js1 ALL INNER JOIN (
|
|
SELECT perf_2.site, perf_2.z AS z_2
|
|
FROM perf AS perf_2
|
|
WHERE user_id = 999
|
|
) js2 USING site);
|
|
|
|
DROP TABLE perf;
|