re organized sql