i have 2 sparql queries ,one fetching total no of defects,and second fetching total no. of test cases .i want divide 1 count result count i.e (total no. of defects/total no. of test cases). how can divide 2 queries result using divide operator.
anyone can suggest me on same?
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) ?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) ?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, "")) ?rtc_merged_defect1_projectarea) } group ?rtc_merged_defect1_projectarea } } //this 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) ?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) ?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, "")) ?rqm_merged_qmtestcase1_projectarea) } group ?rqm_merged_qmtestcase1_projectarea } }
the solution use use 2 sub-select queries (i'm using stubs here since current sparql queries confusing (duplicates , using unnecessary sub-select)):
select (?cnt1/?cnt2 ?result) { // first query { select (count(?s) ?cnt1) { ... } } // second query { select (count(?s) ?cnt2) { ... } } }
Comments
Post a Comment