def category_table_build(osm_table_name, categorysql):
    """
    Returns an SQL OSM category table builder

    Args:
        osm_table_name (string): a OSM PostGIS table name

    Returns:
        sql (string): a sql statement
    """

    sql = ("INSERT INTO category_%s (osm_id, cat) "
           "SELECT DISTINCT osm_id, "
           "%s as cat "
           "FROM %s as osm")
    sql = sql % (osm_table_name, categorysql, osm_table_name)

    return sql