1
I am starting in Laravel (5.2) and need to assemble the query
down in the Builder! Practically it subtracts the previous value from the same column.
It works normally, but I’m migrating to the 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";
I already appreciate any help , Valdir.
You are using [tag:Mysql] as the right database?
– David
I am yes...thanks for the contact.
– Kaztyx