breaking sql into parts