我的问题是在查询中它按原样工作,返回组的最后一个值
SELECT p.promediototalmk
FROM promediogeneral
WHERE id IN (
SELECT MAX(id)
FROM promediogeneral
GROUP BY fecha
) ORDER BY id DESC
但当我完成查询时,它返回的是第一个值,而不是最后一个值
SELECT hora,
(SELECT p.promediototalmk FROM promediogeneral GROUP BY fecha ORDER BY id DESC LIMIT 1) AS OPEN,
(SELECT p.promediototalmk
FROM promediogeneral
WHERE id IN (
SELECT MAX(id)
FROM promediogeneral
GROUP BY fecha
) ORDER BY id DESC LIMIT 1) AS CLOSE,
MIN(promediototalmk) AS ProMin, MAX(promediototalmk) AS ProMax, p.`fecha` as FECHA
FROM promediogeneral p
GROUP BY `fecha` ORDER BY id DESC
结果
Date,Open,High,Low,Close,Volume,Adj Close
2020-06-15,**>>205881.018<<**,206615.32,200749.62,**>>205881.018<<**,0,0
2020-06-14,203554.647,205730.58,199753.08,203554.647,0,0
2020-06-13,201731.652,205091.68,199225.86,201731.652,0,0
db示例
fecha | id | promediototalmk |
2019-02-02 | 1 | 16000.00 |
2019-02-02 | 2 | 17000.00 |
2019-02-03 | 3 | 14000.00 |
2019-02-01 | 4 | 13000.00 |
2019-02-01 | 5 | 15000.00 |
暂无答案!
目前还没有任何答案,快来回答吧!