refactor basesql - leftjoins (now hardcoded)