SQL查询MIN和MAX

时间:2019-06-13 07:02:30

标签: sql

我有一个SQL问题,如何根据查询MAX()MIN()来减少昨天的值?

SELECT mesin,
(SELECT value FROM `exa` WHERE Tanggal in 
(select MAX(Tanggal) 
FROM exa WHERE Tanggal))-(SELECT value FROM `exa` 
WHERE Tanggal in (select MAX(Tanggal) 
FROM exa WHERE Tanggal >= CURRENT_DATE() - INTERVAL 1 DAY AND Tanggal < CURRENT_DATE() ORDER BY Tanggal)) AS hasil FROM `exa` 
WHERE Tanggal in (SELECT MAX(Tanggal) FROM exa WHERE Tanggal)![enter image description here](https://i.stack.imgur.com/I2P8c.png)

0 个答案:

没有答案