SC
Size: a a a
SC
S
A
ЕА
DN
ЕА
SC
WITH sum(data_compressed_bytes) AS compressed_size_bytes
SELECT
database,
table,
name,
any(type) AS type,
any(compression_codec) AS codec,
formatReadableSize(compressed_size_bytes) AS compressed_size
FROM system.columns
GROUP BY database, table, name
ORDER BY database, table, name
ЕА
AS
AS
SELECT
cc.event_date AS date,
pp.segment as segment,
SUM(
CASE
WHEN pp.unit = 0 AND pp.units_count = 7 THEN pp.price_cent / pp.units_count * 28
WHEN pp.unit = 2 AND pp.units_count > 1 THEN pp.price_cent / (pp.units_count * 30) * 28
WHEN pp.unit = 3 THEN pp.price_cent / 365 * 28
ELSE
toFloat64(pp.price_cent)
END
) AS sum
FROM (
SELECT toStartOfInterval(toDateTime(1585699200), INTERVAL 1 week) + INTERVAL number week AS event_date
FROM numbers(toUInt64(dateDiff('week', toDateTime(1585699200), toDateTime(1588204800)) + 1))
) AS cc LEFT JOIN (
SELECT
c.event_date AS join_date,
COALESCE(p.country, 'Unknown') AS segment,
p.unit AS unit,
p.units_count AS units_count,
p.price_cent AS price_cent
FROM (
SELECT toStartOfInterval(toDateTime(1585699200), INTERVAL 1 week) + INTERVAL number week AS event_date
FROM numbers(toUInt64(dateDiff('week', toDateTime(1585699200), toDateTime(1588204800)) + 1))
) AS c CROSS JOIN (
SELECT *
FROM last_purchases
WHERE app_id == '177b6fb0'
AND kind == 0
AND cancelled_at IS NULL
AND is_trial_period == 0
AND is_upgraded == 0
AND expires_at IS NOT NULL
AND purchased_at IS NOT NULL
) AS p WHERE c.event_date BETWEEN p.purchased_at AND p.expires_at
) AS pp ON cc.event_date = pp.join_date
GROUP BY date, segment
ORDER BY date ASC
AS
AT
AT
AT
AS
AL
Y
AL
AL
SC