创建市值高低最新价格的cq - Xiaotian0617/Center GitHub Wiki

CREATE DATABASE "MarketCap" WITH DURATION 31d REPLICATION 1 SHARD DURATION 1h NAME "31d";

CREATE CONTINUOUS QUERY cq_transfer_market_cap ON MarketCap RESAMPLE EVERY 5m FOR 1h BEGIN SELECT last(priceUsd) AS last, max(priceUsd) AS high, min(priceUsd) AS low, last(allDayVolumeUsd) AS volume,last("onlyKey") as onlyKey INTO MarketCap."31d".marketCap FROM TopCoinDB.autogen.marketCap GROUP BY id, time(30m) FILL(null) ORDER BY time DESC LIMIT 1 END

CREATE CONTINUOUS QUERY cq_transfer_market_cap_1d ON MarketCap RESAMPLE EVERY 5m FOR 2d BEGIN SELECT last(last) AS last, max(high) AS high, min(low) AS low, last(volume) AS volume,last(onlyKey) as onlyKey INTO MarketCap."31d".marketCap_1D FROM MarketCap."31d".marketCap GROUP BY id, time(1d) FILL(null) END