SELECT mt1.ids,
mt1.dates,
mt1.times,
mt1.waterflow,
IFNULL(mt1.waterflow - mt2.waterflow, 0) as Diffs
FROM nsd mt1
LEFT JOIN nsd mt2 ON mt2.ids =
(SELECT MAX(ids) FROM nsd mt3 WHERE mt3.ids < mt1.ids AND
mt3.dates BETWEEN '20150519' AND '20150519')
WHERE mt1.dates BETWEEN '20150519' AND '20150519'
ORDER BY mt1.ids
ไม่มีความคิดเห็น:
แสดงความคิดเห็น