s/SELECT DISTINCT/SELECT DISTINCT ON/, I'm bad at reading sometimes :P