what are you using to detect CPU is at 90%? the alert you create does not appear to have the required component of
@performance_condition=N'Resource Pool Stats|CPU usage %|default|>|90',
also, this code is bad;
sum(datediff(second, login_time, getdate()))
WHERE spid > 50
GROUP BY convert(varchar(50), program_name)
ORDER BY 7 DESC
you only have 4 columns.... you can't ORDER BY the 7th column.
It's an interesting approach overall. I am fan of email alerting on certain conditions occuring on the server.