Alert when neighbor OSPF goes down with neighbor has custom properties name SLA either 0 or 1


Can someone join a SQL query when the neighbor node OSFP goes down and when both Router1 and neighbor node have custom properties name SLA either 0 or 1 will trigger an alert. 

Router1, SLA 0 or 1

Neighbor node: SLA 0 or 1

This is my SQL alert query but need to add condition with SLA of both Router1 and Neighbor.

SELECT Nodes.Caption, Nodes.NodeID FROM Nodes
join NodeIPAddresses ni on nodes.nodeid=ni.nodeid
join NPM_RoutingNeighbor_V RN on ni.IPAddress=RN.NeighborIP
WHERE (( (RN.OrionStatus = 2) OR (RN.IsDeleted = 1) )  and nodes.status <> 9 )
group by Nodes.Caption, Nodes.NodeID