Reputation: 199
I want to retrieve the maximum value
of last 10 records in sqlite
database, I use the below query but it retrieve the maximum value
for all the column
not for only the last 10, how I can solve this problem?
select ifnull(Max(Systolic),0) from PressureAndHR order by ID desc limit 10;
Thank u,
Upvotes: 2
Views: 502
Reputation: 7667
try to modify from
select ifnull(Max(Systolic),0) from PressureAndHR order by ID desc limit 10;
to
SELECT ifnull(Max(Systolic),0) FROM (SELECT * PressureAndHR ORDER by ID DESC limit 10);
Upvotes: 2