I have my mysql query, which i use in php script:

```
select distinct dhcp_logs_public.service,
dhcp_logs_public.ip,
dhcp_logs_public.date as date,
dhcp_logs_public.until as until
from dhcp_logs_public
where dhcp_logs_public.ip in('79.109.1.200','71.109.160.123','21.110.151.110')
AND dhcp_logs_public.date >= DATE_ADD(NOW(), INTERVAL -48 Hour)

```

which gives me this kind of result:

```
service         ip                date            until
PONS1   79.109.1.200    11.10.2014 17:17    11.10.2014 19:17
PONS2   71.109.160.123  11.10.2014 19:09    12.10.2014 3:09
PONS2   71.109.160.123  11.10.2014 23:09    12.10.2014 7:09
PONS2   71.109.160.123  12.10.2014 3:09     12.10.2014 11:09
PONS3   71.109.160.123  12.10.2014 7:09     12.10.2014 15:09
PONS4   71.109.160.123  12.10.2014 16:19    12.10.2014 17:19
PONS4   71.109.160.123  12.10.2014 16:49    13.10.2014 0:49
PONS5   21.110.151.110  13.10.2014 9:22     13.10.2014 11:22
PONS5   21.110.151.110  13.10.2014 10:34    13.10.2014 12:34
PONS5   21.110.151.110  13.10.2014 11:46    13.10.2014 13:46
PONS5   21.110.151.110  13.10.2014 11:46    13.10.2014 13:46

```

I need to modify my query to achieve this: (latest record for every ip address)

```
service         ip                date            until
PONS1   79.109.1.200    11.10.2014 17:17    11.10.2014 19:17
PONS4   71.109.160.123  12.10.2014 16:49    13.10.2014 0:49
PONS5   21.110.151.110  13.10.2014 11:46    13.10.2014 13:46

```

I tried things like sub-query, but my table is too large (~ 1 billion rows) to process it quite quickly. Also I tried to add max(date) with group by ip, but no luck..

Any ideas?