Query last 7 days of alert email action history in SWQL

Quick query to pull the last 7 days of alert email action history via SWQL.

SELECT
     ac.Name AS [Alert Configuration]
    ,ah.Message AS [Action Message]
    ,ah.AlertObjects.EntityNetObjectId
    ,ah.EventType
    ,ah.TimeStamp
    ,ah.ActionID
    ,a.ActionTypeID AS [ActionType]
    ,a.Title AS [ActionName]
    ,n.NodeName AS [Node]
FROM Orion.AlertHistory AS ah 
INNER JOIN Orion.Nodes AS n ON CONCAT('N:', TOSTRING(n.NodeID)) = ah.AlertObjects.EntityNetObjectId
LEFT JOIN Orion.Actions AS a ON a.ActionID = ah.ActionID
LEFT JOIN Orion.AlertObjects AS ao ON ah.AlertObjectID = ao.AlertObjectID 
LEFT JOIN Orion.AlertConfigurations AS ac ON ac.AlertID = ao.AlertID 
WHERE a.ActionTypeID = 'Email'
AND DAYDIFF(ah.TimeStamp, GETUTCDATE()) <= 7
ORDER BY ah.TimeStamp DESC

Anonymous