Alerts and NRQL and conditions

I want to integrate 2 events and their 2 values as in total 4 values and make a alert for it if any of the condition fails to successfully validate the data . How can I make such alert using NRQL. One event is custom made using flex and one is log with any same attributes between both the table.