SQL -  remove doubles with self-join