sql for notifications