Updated query to return values ordered by date