SELECT
DISTINCT(id)
FROM
test1
WHERE
date = '2016-10-16 00:00:00'
AND id IN (
SELECT
id
FROM
test1
GROUP BY
id
HAVING
min(date) < '2016-10-16 00:00:00'
)
ORDER BY id
SELECT DISTINCT
(a.id)
FROM
test1 a
INNER JOIN test1 b ON a.id = b.id
WHERE
a.date = '2016-10-16 00:00:00'
AND b.date < '2016-10-16 00:00:00'
ORDER BY
a.id