SQL work, some reordering of things.