It's all about the answers!

Ask a question

how to divide a sparql querry with another Sparql querry in JRS in Advance tab


Krunal Gaoli (671269) | asked Apr 07 '17, 5:45 a.m.

  Hi All,

 

I have two SPARQL queries ,one fetching the total no of defects,and second fetching the total no. of test cases .I want to divide one count result to another count i.e (total no. of defects/total no. of test cases). How can I divide two queries result using divide operator. <o:p> </o:p>

 

Anyone can suggest me on same? <o:p> </o:p>

 

Thank you in advance. <o:p> </o:p>

 

PREFIX process: <http://jazz.net/ns/process#> <o:p> </o:p>

    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> <o:p> </o:p>

    PREFIX merge: <http://jazz.net/ns/lqe/merge/> <o:p> </o:p>

    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> <o:p> </o:p>

    PREFIX owl: <http://www.w3.org/2002/07/owl#> <o:p> </o:p>

    PREFIX oslc: <http://open-services.net/ns/core#> <o:p> </o:p>

    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <o:p> </o:p>

    PREFIX skos: <http://www.w3.org/2004/02/skos/core#> <o:p> </o:p>

    PREFIX rtc_merged: <http://jazz.net/ns/lqe/merge/gensym/cm/> <o:p> </o:p>

    PREFIX oslc_config: <http://open-services.net/ns/config#> <o:p> </o:p>

    PREFIX dcterms: <http://purl.org/dc/terms/> <o:p> </o:p>

 

 

    SELECT DISTINCT <o:p> </o:p>

      ?rtc_merged_Defect1_projectArea <o:p> </o:p>

      ?rtc_merged_Defect1_shortId_COUNT <o:p> </o:p>

    WHERE{ <o:p> </o:p>

      { <o:p> </o:p>

        SELECT DISTINCT <o:p> </o:p>

          ?rtc_merged_Defect1_projectArea <o:p> </o:p>

          (COUNT(DISTINCT ?rtc_merged_Defect1_shortId) AS ?rtc_merged_Defect1_shortId_COUNT) <o:p> </o:p>

        WHERE{ <o:p> </o:p>

          VALUES( ?rtc_merged_Defect1_paUri ) <o:p> </o:p>

          { <o:p> </o:p>

            ( <https://localhost:9443/ccm/process/project-areas/__ANzQBasEeegkPxZTDywOA> ) <o:p> </o:p>

          } <o:p> </o:p>

          ?rtc_merged_Defect1_uri process:projectArea ?rtc_merged_Defect1_paUri. <o:p> </o:p>

          ?rtc_merged_Defect1_uri oslc:instanceShape ?rtc_merged_Defect1_uri_instanceShape. <o:p> </o:p>

          ?rtc_merged_Defect1_uri_instanceShape merge:mergeShape rtc_merged:Defect. <o:p> </o:p>

          OPTIONAL { <o:p> </o:p>

            ?rtc_merged_Defect1_uri process:projectArea ?rtc_merged_Defect1_projectArea_enumValue. <o:p> </o:p>

            OPTIONAL {?rtc_merged_Defect1_projectArea_enumValue rdfs:label|dcterms:title ?rtc_merged_Defect1_projectArea_enumName.} <o:p> </o:p>

          } <o:p> </o:p>

          OPTIONAL {?rtc_merged_Defect1_ver dcterms:isVersionOf ?rtc_merged_Defect1_uri; rdf:type oslc_config:VersionResource.} <o:p> </o:p>

          ?rtc_merged_Defect1_uri oslc:shortId ?rtc_merged_Defect1_shortId. <o:p> </o:p>

          BIND( IF (bound(?rtc_merged_Defect1_ver), concat(str(?rtc_merged_Defect1_uri), "?oslc_config.context="), ?rtc_merged_Defect1_uri) as ?rtc_merged_Defect1) <o:p> </o:p>

          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) <o:p> </o:p>

        } <o:p> </o:p>

        GROUP BY ?rtc_merged_Defect1_projectArea <o:p> </o:p>

      } <o:p> </o:p>

    }  //This is my first query. <o:p> </o:p>

=============================================================== <o:p> </o:p>

 

 

PREFIX process: <http://jazz.net/ns/process#> <o:p> </o:p>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> <o:p> </o:p>

PREFIX merge: <http://jazz.net/ns/lqe/merge/> <o:p> </o:p>

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> <o:p> </o:p>

PREFIX owl: <http://www.w3.org/2002/07/owl#> <o:p> </o:p>

PREFIX oslc: <http://open-services.net/ns/core#> <o:p> </o:p>

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <o:p> </o:p>

PREFIX rqm_merged: <http://jazz.net/ns/lqe/merge/gensym/qm/> <o:p> </o:p>

PREFIX skos: <http://www.w3.org/2004/02/skos/core#> <o:p> </o:p>

PREFIX oslc_config: <http://open-services.net/ns/config#> <o:p> </o:p>

PREFIX dcterms: <http://purl.org/dc/terms/> <o:p> </o:p>

 

 

SELECT DISTINCT <o:p> </o:p>

  ?rqm_merged_QMTestCase1_projectArea <o:p> </o:p>

  ?rqm_merged_QMTestCase1_shortId_COUNT <o:p> </o:p>

WHERE{ <o:p> </o:p>

  { <o:p> </o:p>

    SELECT DISTINCT <o:p> </o:p>

      ?rqm_merged_QMTestCase1_projectArea <o:p> </o:p>

      (COUNT(DISTINCT ?rqm_merged_QMTestCase1_shortId) AS ?rqm_merged_QMTestCase1_shortId_COUNT) <o:p> </o:p>

    WHERE{ <o:p> </o:p>

      VALUES( ?rqm_merged_QMTestCase1_paUri ) <o:p> </o:p>

      { <o:p> </o:p>

        ( <https://localhost:9443/qm/process/project-areas/_EazMoBatEeeR-7d5-ZtSzw> ) <o:p> </o:p>

      } <o:p> </o:p>

      ?rqm_merged_QMTestCase1_uri process:projectArea ?rqm_merged_QMTestCase1_paUri. <o:p> </o:p>

      ?rqm_merged_QMTestCase1_uri oslc:instanceShape ?rqm_merged_QMTestCase1_uri_instanceShape. <o:p> </o:p>

      ?rqm_merged_QMTestCase1_uri_instanceShape merge:mergeShape rqm_merged:QM%20Test%20Case. <o:p> </o:p>

      OPTIONAL { <o:p> </o:p>

        ?rqm_merged_QMTestCase1_uri process:projectArea ?rqm_merged_QMTestCase1_projectArea_enumValue. <o:p> </o:p>

        OPTIONAL {?rqm_merged_QMTestCase1_projectArea_enumValue rdfs:label|dcterms:title ?rqm_merged_QMTestCase1_projectArea_enumName.} <o:p> </o:p>

      } <o:p> </o:p>

      OPTIONAL {?rqm_merged_QMTestCase1_ver dcterms:isVersionOf ?rqm_merged_QMTestCase1_uri; rdf:type oslc_config:VersionResource.} <o:p> </o:p>

      ?rqm_merged_QMTestCase1_uri oslc:shortId ?rqm_merged_QMTestCase1_shortId. <o:p> </o:p>

      BIND( IF (bound(?rqm_merged_QMTestCase1_ver), concat(str(?rqm_merged_QMTestCase1_uri), "?oslc_config.context="), ?rqm_merged_QMTestCase1_uri) as ?rqm_merged_QMTestCase1) <o:p> </o:p>

      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) <o:p> </o:p>

    } <o:p> </o:p>

    GROUP BY ?rqm_merged_QMTestCase1_projectArea <o:p> </o:p>

  } <o:p> </o:p>

} <o:p> </o:p>

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.