Refactory sql of dormitory.