begin assembling the sql for this