sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

31_Select_the_average_number_of_citation_of_reactions_that_have_at_least_one_citation

rq turtle/ttl

Select the average number of citation of reactions that have at least one citation

Use at

PREFIX rh: <http://rdf.rhea-db.org/>

SELECT (AVG(?linksToPubmedPerReaction) AS ?avgLinksToPubmedPerReaction)
WHERE
{
    SELECT ?reaction (COUNT(DISTINCT ?citation) AS ?linksToPubmedPerReaction)
    WHERE
    {
        ?reaction rh:citation ?citation .
    }
GROUP BY ?reaction ORDER BY DESC(?linksToPubmedPerReaction)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?avgLinksToPubmedPerReaction")
  v3("?citation")
  v4("?linksToPubmedPerReaction"):::projected 
  v2("?reaction")
  v2 --"rh:citation"-->  v3
  bind1[/"count(?citation)"/]
  v3 --o bind1
  bind1 --as--o v4
  bind3[/"average(?linksToPubmedPerReaction)"/]
  v4 --o bind3
  bind3 --as--o v4