我有兩個SPARQL查詢,一個提取缺陷總數,第二個提取總數no。的測試用例。我想將一個計數結果除以另一個計數,即(缺陷總數/測試用例的總數)。 如何使用除法運算符分割兩個查詢結果。SPARQL從兩個查詢中劃分兩個值
任何人都可以建議我一樣嗎?
PREFIX process: <http://jazz.net/ns/process#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX merge: <http://jazz.net/ns/lqe/merge/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oslc: <http://open-services.net/ns/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rtc_merged: <http://jazz.net/ns/lqe/merge/gensym/cm/>
PREFIX oslc_config: <http://open-services.net/ns/config#>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT DISTINCT
?rtc_merged_Defect1_projectArea
?rtc_merged_Defect1_shortId_COUNT
WHERE{
{
SELECT DISTINCT
?rtc_merged_Defect1_projectArea
(COUNT(DISTINCT ?rtc_merged_Defect1_shortId) AS ?rtc_merged_Defect1_shortId_COUNT)
WHERE{
VALUES(?rtc_merged_Defect1_paUri)
{
(<https://localhost:9443/ccm/process/project-areas/__ANzQBasEeegkPxZTDywOA>)
}
?rtc_merged_Defect1_uri process:projectArea ?rtc_merged_Defect1_paUri.
?rtc_merged_Defect1_uri oslc:instanceShape ?rtc_merged_Defect1_uri_instanceShape.
?rtc_merged_Defect1_uri_instanceShape merge:mergeShape rtc_merged:Defect.
OPTIONAL {
?rtc_merged_Defect1_uri process:projectArea ?rtc_merged_Defect1_projectArea_enumValue.
OPTIONAL {?rtc_merged_Defect1_projectArea_enumValue rdfs:label|dcterms:title ?rtc_merged_Defect1_projectArea_enumName.}
}
OPTIONAL {?rtc_merged_Defect1_ver dcterms:isVersionOf ?rtc_merged_Defect1_uri; rdf:type oslc_config:VersionResource.}
?rtc_merged_Defect1_uri oslc:shortId ?rtc_merged_Defect1_shortId.
BIND(IF (bound(?rtc_merged_Defect1_ver), concat(str(?rtc_merged_Defect1_uri), "?oslc_config.context="), ?rtc_merged_Defect1_uri) as ?rtc_merged_Defect1)
BIND(IF(bound(?rtc_merged_Defect1_projectArea_enumName), ?rtc_merged_Defect1_projectArea_enumName, IF(bound(?rtc_merged_Defect1_projectArea_enumValue), ?rtc_merged_Defect1_projectArea_enumValue, "")) as ?rtc_merged_Defect1_projectArea)
}
GROUP BY ?rtc_merged_Defect1_projectArea
}
} //This is my first query.
===============================================================
PREFIX process: <http://jazz.net/ns/process#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX merge: <http://jazz.net/ns/lqe/merge/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oslc: <http://open-services.net/ns/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rqm_merged: <http://jazz.net/ns/lqe/merge/gensym/qm/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX oslc_config: <http://open-services.net/ns/config#>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT DISTINCT
?rqm_merged_QMTestCase1_projectArea
?rqm_merged_QMTestCase1_shortId_COUNT
WHERE{
{
SELECT DISTINCT
?rqm_merged_QMTestCase1_projectArea
(COUNT(DISTINCT ?rqm_merged_QMTestCase1_shortId) AS ?rqm_merged_QMTestCase1_shortId_COUNT)
WHERE{
VALUES(?rqm_merged_QMTestCase1_paUri)
{
(<https://localhost:9443/qm/process/project-areas/_EazMoBatEeeR-7d5-ZtSzw>)
}
?rqm_merged_QMTestCase1_uri process:projectArea ?rqm_merged_QMTestCase1_paUri.
?rqm_merged_QMTestCase1_uri oslc:instanceShape ?rqm_merged_QMTestCase1_uri_instanceShape.
?rqm_merged_QMTestCase1_uri_instanceShape merge:mergeShape rqm_merged:QM%20Test%20Case.
OPTIONAL {
?rqm_merged_QMTestCase1_uri process:projectArea ?rqm_merged_QMTestCase1_projectArea_enumValue.
OPTIONAL {?rqm_merged_QMTestCase1_projectArea_enumValue rdfs:label|dcterms:title ?rqm_merged_QMTestCase1_projectArea_enumName.}
}
OPTIONAL {?rqm_merged_QMTestCase1_ver dcterms:isVersionOf ?rqm_merged_QMTestCase1_uri; rdf:type oslc_config:VersionResource.}
?rqm_merged_QMTestCase1_uri oslc:shortId ?rqm_merged_QMTestCase1_shortId.
BIND(IF (bound(?rqm_merged_QMTestCase1_ver), concat(str(?rqm_merged_QMTestCase1_uri), "?oslc_config.context="), ?rqm_merged_QMTestCase1_uri) as ?rqm_merged_QMTestCase1)
BIND(IF(bound(?rqm_merged_QMTestCase1_projectArea_enumName), ?rqm_merged_QMTestCase1_projectArea_enumName, IF(bound(?rqm_merged_QMTestCase1_projectArea_enumValue), ?rqm_merged_QMTestCase1_projectArea_enumValue, "")) as ?rqm_merged_QMTestCase1_projectArea)
}
GROUP BY ?rqm_merged_QMTestCase1_projectArea
}
}
您的第一個和第二個查詢完全相同。 – AKSW
我不明白你爲什麼在查詢中有一個子SELECT。 – AKSW