Generates the SQL neccessary for EventAI in MANGOS based on some parameters