# Policy - Rule Detail Compliance

**URL:** <https://discuss.rapid7.com/t/policy-rule-detail-compliance/43457>\
**Category:** InsightVM\
**Tags:** sql, queries\
**Created:** [October 9, 2024, 10:26pm UTC](https://discuss.rapid7.com/t/policy-rule-detail-compliance/43457 "2024-10-09T22:26:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyber\_security](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/c/b487fb/32.png) [@cyber\_security](https://discuss.rapid7.com/u/cyber_security)\
**Post date:** [October 9, 2024, 10:26pm UTC](https://discuss.rapid7.com/t/policy-rule-detail-compliance/43457/1 "2024-10-09T22:26:26Z")

</div>

Hello,  
I want to create a report that includes the following elements:  
host\_name,ip\_address,OS Name, policy\_title,rule\_name,compliance\_status,last\_scan

Example of field values  
|host\_name|ip\_address|OS Name|policy\_title|rule\_name|compliance\_status|last\_scan|  
|servername|192.168.0.1|Microsoft Windows Server 2019 Standard Edition 1809|CIS Microsoft Windows Server 2019 Benchmark Level 1 - Domain Controller|2.2.11. (L1) Ensure ‘Change the system time’ is set to ‘Administrators, LOCAL SERVICE’|Failed|2024-09-09 04:22:44.163|

I used this query, but it’s not working; there is an issue with the joins.  
SELECT  
da.host\_name,  
da.ip\_address,  
dos.description as OS Name,  
dp.title AS policy\_title,  
dpr.title AS rule\_name,  
CASE  
WHEN fapr.compliance = TRUE THEN ‘Passed’  
WHEN fapr.compliance = FALSE THEN ‘Failed’  
ELSE ‘Not applicable’  
END AS compliance\_status,  
da.last\_assessed\_for\_vulnerabilities AS last\_scan

FROM fact\_asset\_policy\_rule fapr  
JOIN dim\_asset da ON fapr.asset\_id = da.asset\_id  
JOIN dim\_operating\_system dos ON da.operating\_system\_id = dos.operating\_system\_id  
JOIN dim\_policy\_rule dpr ON fapr.policy\_id = dpr.policy\_id AND fapr.rule\_id = dpr.rule\_id  
JOIN dim\_policy dp ON fapr.policy\_id = dp.policy\_id

WHERE dp.title LIKE ‘%CIS Microsoft Windows Server 2019 Level Two - Member Server v1.3.0’  
AND da.last\_assessed\_for\_vulnerabilities \>= CURRENT\_DATE - INTERVAL ‘30 days’;

Thank you

---

<div class="post-metadata">

**Author:** ![Matthew\_Cavaco](https://discuss.rapid7.com/letter_avatar_proxy/v4/letter/m/839c29/32.png) [@Matthew\_Cavaco](https://discuss.rapid7.com/u/Matthew_Cavaco)\
**Post date:** [December 31, 2024, 9:40pm UTC](https://discuss.rapid7.com/t/policy-rule-detail-compliance/43457/2 "2024-12-31T21:40:21Z")

</div>

Hi @cyber_security,

This is Matt Cavaco from the Rapid7 Customer Success team!

I realize this post is from October 9, 2024 so I’m not sure if you’ve already received help with this question or not.

Have you brought this question to your dedicated Customer Success Manager? If not, I’m happy to get you connected so we can identify the best resource at Rapid7 to help.

Matt Cavaco
