Refine sql homework