I have a table as shown here below.

[![enter image description here](https://i.stack.imgur.com/8EzBW.png)](https://i.stack.imgur.com/8EzBW.png)

I want to select the `id_start_odon` with a particular `id_pasien` and the last date of that particular `id_pasien`. I want to get 15 as the result. I've tried this but it doesn't render what I want.

```
public function get_latest($id_pasien){
    $query = "SELECT s1.id_start_odon FROM start_odon s1 WHERE s1.id_pasien=$id_pasien AND s1.created_at=(SELECT s2* FROM start_odon s2 WHERE s2.id_pasien=$id_pasien AND s2.created_at=MAX(s2.created_at))";
    $res = $this->db->query($query);
    return $query;

}

```

Any suggestions are appreciated.