Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Consulta MySQL para obter valores diferenciais diários


Tente esta consulta -
SELECT
  t1.dt AS date,
  t1.value - t2.value AS value
FROM
  (SELECT DATE(date) dt, MAX(value) value FROM table GROUP BY dt) t1
JOIN
  (SELECT DATE(date) dt, MAX(value) value FROM table GROUP BY dt) t2
    ON t1.dt = t2.dt + INTERVAL 1 DAY