postgresql merge into using select