我正在使用TopBraid Composer中的SPARQL查询来获取每个月的数据质量规则数.
我有一个开始日期和结束日期,但我需要获取开始日期和结束日期之间的所有月份,以便我可以获得适用于该持续时间的数据质量规则的计数.
我当前的查询和结果如下 - :
SELECT *
WHERE
{
?Rules CDE:Data_Quality_Rule_added_on ?Date1.
?Rules CDE:Data_Quality_Removed_On ?Date2
BIND(month(?Date1) AS ?Month1)
BIND(month(?Date2) AS ?Month2)
BIND(smf:duration("mon",?Date1,?Date2) AS ?dur)
}
LIMIT 5
| [Rules] | Date1 | Date2 | Month1 | Month2 | dur
| CDE:Data_Quality_Rule_13 | 2016-01-28 | 2016-09-15 | 01 | 09 | 8
| CDE:Data_Quality_Rule_16 | 2016-02-29 | 2016-08-08 | 02 | 08 | 5
| CDE:Data_Quality_Rule_18 | 2016-05-15 | 2016-10-31 | 05 | 10 | 6
| …Run Code Online (Sandbox Code Playgroud)