2017-11-24 2 views
0

私のdb測定では、タグは「ソース」、「エディション」、「日付」、フィールドは「カウント」です。influxdbのlast(sum(count))を見つける方法は?

各ソースには複数のエディションがあります。私はエディションに基づいてデータをプッシュしています。

各ソースのエディションの合計が必要です。私は通常のクエリでそれを得ることができます。

しかし、ここでは複数の日付にしたいです。ネストされた関数または関数の関数を使用することによっても可能です。

select mean(sum),last(sum) from (select sum(count) from epaper_edition where (date='2017-11-03' or date='2017-11-04' or date='2017-11-05' or date='2017-11-06') group by date,source) group by source


last()

関数は、タイムスタンプに基づいています。 last(sum(count))の結果はランダムsum(count)であり、最後のものではありません。

最後の日付に別のクエリsum(count)を使用して解決策があります。私は1つのクエリでそれが必要です。

私はこれに対してより良い解決策を提供してくれてありがとうございます。

答えて

0

ソースごとに個々のエディションの合計が必要な場合は、ソースと同様にエディションごとにグループ化する必要があります。

select mean(sum),last(sum) from (select sum(count) from epaper_edition where (date='2017-11-03' or date='2017-11-04' or date='2017-11-05' or date='2017-11-06') group by date, source, edition) group by source, edition

関連する問題