I'm starting out in Laravel (5.2) and I need to mount query
down in Builder ! Pretty much it subtracts the previous value from the same column.
It works normally, but I'm migrating to Laravel.
$query = "SELECT tbl_leitura_gas.id_leitura
,tbl_leitura_gas.data_leitura
,tbl_leitura_gas.valor_leitura
,tbl_leitura_gas.data_cadastro
,ifnull(valor_leitura -
(SELECT mt.valor_leitura
FROM tbl_leitura_gas mt
WHERE mt.data_leitura < tbl_leitura_gas.data_leitura
ORDER BY mt.data_leitura DESC LIMIT 0
,1)
,0) AS consumo_m3
FROM tbl_leitura_gas
ORDER BY tbl_leitura_gas.data_leitura DESC";
Thanks in advance for any help, Valdir.