I have a query which shows me the average of the previous day of a column:
$date = date("Y-m-d");
$estacion=2;
$sql="SELECT AVG(TS) as TSprom
FROM sensores
WHERE date<'$date' ";
so far so good, but when I put the id as a condition, it shows me another value from other days, not the day before the current one.
$date = date("Y-m-d");
$estacion=2;
$sql="SELECT AVG(TS) as TSprom1
FROM sensores
WHERE date<'$date' AND idestacion='$estacion' ";
I hope you can help me, thanks