Finalize the SQL for matching buildings. This finishes the code
for issue #3 but not the docs