> On Dec 20, 2018, at 4:21 PM, Jungle Boogie <[email protected]> wrote:
>
> select od_reading from mileage where car='foo' limit 1
> select od_reading from mileage where car='bar' order by od_reading desc limit
> 1
Note: the first query should use “order by od_reading”, otherwise the order is
undefined.
A clearer way to specify these is
select min(od_reading) from mileage where car=‘foo’
select max(od_reading) from mileage where car=‘foo’
> How do I subtract the last query from the first query to determine how many
> miles were driven?
It’s super simple:
(select od_reading from mileage where car='foo' limit 1) - (select od_reading
from mileage where car='bar' order by od_reading desc limit 1)
—Jens
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users