aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2017-11-27 12:49:35 +0100
committermarcinzelent <zelent.marcin@gmail.com>2017-11-27 12:49:35 +0100
commit3c203d43f67212570318a4fea4bc68fac13c581f (patch)
treed57a9095278b160c61cc5852ec1d6c810bf83bcb /AirPollutionWebApi/Controllers/ReadingsController.cs
parent10bc4d0f275f5183da672ece1d7dfa5da8375b3f (diff)
Fixed getting latest reading.
Diffstat (limited to 'AirPollutionWebApi/Controllers/ReadingsController.cs')
-rw-r--r--AirPollutionWebApi/Controllers/ReadingsController.cs3
1 files changed, 2 insertions, 1 deletions
diff --git a/AirPollutionWebApi/Controllers/ReadingsController.cs b/AirPollutionWebApi/Controllers/ReadingsController.cs
index 480d8c0..99965e6 100644
--- a/AirPollutionWebApi/Controllers/ReadingsController.cs
+++ b/AirPollutionWebApi/Controllers/ReadingsController.cs
@@ -30,7 +30,8 @@ namespace AirPollutionWebApi.Controllers
[Route("api/Readings/latest")]
public IHttpActionResult GetLatestReading()
{
- var command = "SELECT MAX(TimeStamp) FROM Readings";
+ var command = "SELECT * FROM Readings " +
+ "WHERE TimeStamp IN(SELECT MAX(TimeStamp) FROM Readings)";
var reading = SqlOperator.GetReadings(command)[0];
if (reading != null) return Ok(reading);