SQL Generator problem being solved