Correct the patient table merging related sql.

Correct the patient table merging related sql.