Fix wrong sql of event