added functions sql, total, count