sql stuff w alerts