sparql-examples

A set of SPARQL examples

View the Project on GitHub Adafede/sparql-examples

wd_authors_expertise

rq turtle/ttl

Authors (females) with expertise in proteomics and computational biology.

Use at


PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#title: Authors (females (Q6581072)) with expertise in proteomics (Q471857) and computational biology (Q177005)
SELECT ?author ?authorLabel ?works ?awards WHERE {
    {
        SELECT DISTINCT ?author ?authorLabel (COUNT(DISTINCT ?output) AS ?works) (COUNT(DISTINCT ?award) AS ?awards) WHERE {
            {
                SELECT DISTINCT * WHERE {
                    { ?author (^wdt:P50/wdt:P921) wd:Q471857, wd:Q177005. }
                    UNION
                    { ?author wdt:P101 wd:Q471857, wd:Q177005.}
                    ?author wdt:P21 wd:Q6581072;
                    rdfs:label ?authorLabel.
                    FILTER((LANG(?authorLabel)) = "en")
                }
            }
            OPTIONAL { ?author wdt:P166 ?award. }
            OPTIONAL { ?author ^wdt:P50 ?output. }
        }
        GROUP BY ?author ?authorLabel
    }
}
ORDER BY DESC (?works) DESC (?awards) DESC (?count)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?author"):::projected 
  v4("?authorLabel"):::projected 
  v6("?award")
  v8("?awards"):::projected 
  v3("?count")
  v7("?output")
  v8("?works"):::projected 
  a1((" "))
  c4(["wd:Q471857"]):::iri 
  c8(["wd:Q6581072"]):::iri 
  c5(["wd:Q177005"]):::iri 
  f0[["?authorLabel = 'en'"]]
  f0 --> v4
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v5 --"wdt:P101"-->  c4
    v5 --"wdt:P101"-->  c5
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    a1 --"wdt:P50"-->  v5
    a1 --"wdt:P921"-->  c4
    a1 --"wdt:P50"-->  v5
    a1 --"wdt:P921"-->  c5
  end
  union0r <== or ==> union0l
  end
  v5 --"wdt:P21"-->  c8
  v5 --"rdfs:label"-->  v4
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v5 -."wdt:P166".->  v6
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v7 -."wdt:P50".->  v5
  end
  bind3[/"count(?output)"/]
  v7 --o bind3
  bind3 --as--o v8
  bind4[/"count(?award)"/]
  v6 --o bind4
  bind4 --as--o v8