RAWSQLAGG_INT("SUM(%1)", [Units]) sends SUM(Units) to the database once per mark and reads a whole number back. In SQL, write the aggregate with the column in place of %1 and GROUP BY the view's dimensions. COUNT(%1) counts non-null values only, which is not the same as counting rows.
The first argument after the SQL string. %2 is the second, and so on, whatever order the placeholders appear in the text. To translate a RAWSQL call, replace each %n with the column it points at and keep the rest of the text.
Does Tableau check the SQL inside RAWSQL?
No. Tableau passes the text to the database as it is, so a typo or a function your database lacks fails at query time, in the database. The text is also tied to that database's dialect: point the workbook at a different database and the same text can fail or mean something else.
What is the difference between RAWSQL and RAWSQLAGG?
RAWSQL_ functions are row-level: the expression runs once per row. RAWSQLAGG_ functions hold an aggregate such as SUM(%1) and run once per mark, grouped by the dimensions in the view. In SQL the first is a plain column expression; the second needs a GROUP BY on the view's dimensions.