0
+---------+----------------------------+------------+------------+------------+--------------+-----------+
| Id | Date | Quantity | Price | Total | FillType | OrderType |
+---------+----------------------------+------------+------------+------------+--------------+-----------+
| 9362090 | 2017-09-04 10:59:28.237000 | 0.01643553 | 0.0196 | 0.00032213 | PARTIAL_FILL | SELL |
| 9362089 | 2017-09-04 10:59:28.237000 | 0.345 | 0.0197 | 0.0067965 | FILL | SELL |
| 9362087 | 2017-09-04 10:58:49.017000 | 0.655 | 0.0197 | 0.0129035 | PARTIAL_FILL | SELL |
| 9362086 | 2017-09-04 10:58:49.017000 | 0.345 | 0.01970001 | 0.0067965 | FILL | SELL |
| 9362078 | 2017-09-04 10:57:24.453000 | 1 | 0.0199 | 0.0199 | FILL | SELL |
| 9362077 | 2017-09-04 10:57:15.093000 | 5.3580217 | 0.01999296 | 0.10712271 | FILL | BUY |
| 9362076 | 2017-09-04 10:57:15.093000 | 0.76888586 | 0.01999237 | 0.01537185 | PARTIAL_FILL | BUY |
| 9362075 | 2017-09-04 10:57:15.093000 | 0.28599999 | 0.01999235 | 0.00571781 | PARTIAL_FILL | BUY |
| 9362061 | 2017-09-04 10:52:32.660000 | 0.055 | 0.01999249 | 0.00109958 | FILL | BUY |
| 9362030 | 2017-09-04 10:48:03.530000 | 0.0279849 | 0.01999262 | 0.00055949 | FILL | BUY |
| 9362029 | 2017-09-04 10:48:03.530000 | 0.40474542 | 0.01999262 | 0.00809192 | PARTIAL_FILL | BUY |
| 9361976 | 2017-09-04 10:20:32.600000 | 0.38150547 | 0.0196015 | 0.00747807 | FILL | BUY |
| 9361974 | 2017-09-04 10:20:08.850000 | 1.58443174 | 0.01950609 | 0.03090606 | PARTIAL_FILL | SELL |
如何獲得每分鐘的量行的總和,但如果沒有在任何微小的數據返回0。按時間Mysql的選擇數據,但不與0值
無視時代我使用的是什麼,但是在沒有任何音量的時候它不會返回0。
select sum(Quantity) from database.table GROUP BY (UNIX_TIMESTAMP(Date)) DIV 30
理想情況下,輸出會是這樣的
2017-09-04 10:59 - 0.5321
2017-09-04 10:58 - 1.000
2017-09-04 10:57 - 6.604
2017-09-04 10:56 - 0
2017-09-04 10:55 - 0
..........
感謝,如果有人可以提供幫助。
您需要填充派生表的每一分鐘,和'左JOIN'它來查詢與'COALESCE() '。 – sagi
這實際上是一個顯示問題,因此,最好在應用程序代碼中處理。 – Strawberry
你可能需要有一個每分鐘的時間列表,並有一個左加入它 –