Moim ulubionym sposobem konstruowania tego kodu SQL jest użycie not exists
klauzula jak tak:
SELECT apntoken,deviceid,created
FROM `distribution_mobiletokens` as dm
WHERE userid='20'
and not exists (
select 1
from `distribution_mobiletokens`
where userid = '20'
and deviceid = dm.deviceid
and created > dm.created
)