Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL-Abfrage, um tägliche Differenzwerte zu erhalten

Versuchen Sie diese Abfrage -

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