mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-20 15:30:50 +00:00
65 lines
1.3 KiB
SQL
65 lines
1.3 KiB
SQL
DROP TABLE IF EXISTS installation_stats;
|
|
CREATE TABLE installation_stats (message String, info String, message_type String) ENGINE = Log;
|
|
|
|
SELECT count(*) AS total
|
|
FROM
|
|
(
|
|
SELECT
|
|
message,
|
|
info,
|
|
count() AS cnt
|
|
FROM installation_stats
|
|
WHERE message_type LIKE 'fail'
|
|
GROUP BY
|
|
message,
|
|
info
|
|
ORDER BY cnt DESC
|
|
LIMIT 5 BY message
|
|
);
|
|
|
|
DROP TABLE installation_stats;
|
|
|
|
CREATE TEMPORARY TABLE Accounts (AccountID UInt64, Currency String);
|
|
|
|
SELECT AccountID
|
|
FROM
|
|
(
|
|
SELECT
|
|
AccountID,
|
|
Currency
|
|
FROM Accounts
|
|
LIMIT 2 BY Currency
|
|
);
|
|
|
|
CREATE TEMPORARY TABLE commententry1 (created_date Date, link_id String, subreddit String);
|
|
INSERT INTO commententry1 VALUES ('2016-01-01', 'xyz', 'cpp');
|
|
|
|
SELECT concat('http://reddit.com/r/', subreddit, '/comments/', replaceRegexpOne(link_id, 't[0-9]_', ''))
|
|
FROM
|
|
(
|
|
SELECT
|
|
y,
|
|
subreddit,
|
|
link_id,
|
|
cnt
|
|
FROM
|
|
(
|
|
SELECT
|
|
created_date AS y,
|
|
link_id,
|
|
subreddit,
|
|
count(*) AS cnt
|
|
FROM commententry1
|
|
WHERE toYear(created_date) = 2016
|
|
GROUP BY
|
|
y,
|
|
link_id,
|
|
subreddit
|
|
ORDER BY y ASC
|
|
)
|
|
ORDER BY
|
|
y ASC,
|
|
cnt DESC
|
|
LIMIT 1 BY y
|
|
);
|