SELECT (SELECT COUNT(*) FROM CLOG{0} WHERE STCODE={DE} AND EVTYPE = 1 AND QUAL = 8 AND SERIALNO={ME} AND LOGDATE >= DATEADD(HH,-24,GETUTCDATE()) + (SELECT COUNT(*) FROM CLOG{1} WHERE STCODE={DE} AND EVTYPE = 1 AND QUAL = 8 AND SERIALNO={ME} AND LOGDATE >= DATEADD(HH,-24,GETUTCDATE()))) /* This is used to see if there were contacts made. (This dives deeper into the CLOG table than most have access to. Please be sure that you double check your work before delivering any queries.) SELECT - Launches the begining of the query to look for data in the database. ( - Contains the first query section. SELECT COUNT(*) FROM CLOG{0} - Pulling the raw number of events that match the remainder of the query. WHERE - Establishes the parameters that will limit the results. STCODE={DE} - STCODE = {DE} looks to match the event code of the event in question to the eventcode that matches the alarm. AND EVTYPE = 1 - EVTYPE = 1 looks for only alarm events. If looking for any events you can change this to EVTYPE in (0, 1, 9) AND QUAL = 8 - QUAL = 8 comes from ManDD and it is looking for the notifiation made. AND SERIALNO={ME} - SERIALNO = {ME} looks for the customer that matches the customer from the event. AND LOGDATE >= DATEADD(HH,-24,GETUTCDATE() - Looks at the log date and the last 24 hours. ) - Closes the containment of the first section of the query + - Concatinates the two queries ( - The following is the same query, just looking at last month. (CLOG{1}) SELECT COUNT(*) FROM CLOG{1} WHERE STCODE={DE} AND EVTYPE = 1 AND QUAL = 8 AND SERIALNO={ME} AND LOGDATE >= DATEADD(HH,-24,GETUTCDATE() ) )) - Closes the complete query. */