Salary formula with sql command risks

Hi all,
Need to have total sales (Sales person) per employee…
Now what are the risks of having a formula or the system allowing on HR to type an sql command ex. (select sum(total) from tabSales Invoices where sales person like employee name).

The ability to select any or all doctypes where employee is used.

I know that at the moment it does not support and will have to do a custom script… But think is something to think about??

Did you miss this?

I have checked this… but imagine that Employee 1 was on 2 Sales Orders/Sales Invoice and Employee 2 was on 3 Sales Invoices … at the end of the month as an Extra or Bonus payment they SUM all Sales done per Employee and pay when processing Salary…

Reason for this is to be able from HR Formula / Salary Structure to be able to reach that doctype and query per Employee.

Otherwise more custom script must be done .