0
給出的僞表:SQL應用公式AVG值
+-----+---------------------+------+
| tag | data | read |
+-----+---------------------+------+
| A | 2013-10-10 15:00:00 | 1345 |
+-----+---------------------+------+
| A | 2013-10-10 15:15:00 | 3454 |
+-----+---------------------+------+
| A | 2013-10-10 15:30:00 | 2345 |
+-----+---------------------+------+
| A | 2013-10-10 15:45:00 | 1132 |
+-----+---------------------+------+
| B | 2013-10-10 15:00:00 | 6234 |
+-----+---------------------+------+
| B | 2013-10-10 15:15:00 | 5432 |
+-----+---------------------+------+
| B | 2013-10-10 15:30:00 | 4563 |
+-----+---------------------+------+
| B | 2013-10-10 15:45:00 | 5432 |
+-----+---------------------+------+
是否有可能只適用於使用SQL下面的公式?
實施例:
result=AVG(A)-(AVG(B)+AVG(C))
或
result=AVG(A)+AVG(B)
由日期分組?
它工作正常的操作選擇。但必須刪除「其他0」,因爲它會影響平均計算,所以'... AVG(CASE當標籤='A'然後讀完)...' –
你是對的。我糾正了它。 – sqlint