query-4f660220fafbb5564f1ff2eceaee63c5

rq turtle/ttl

Find people with multiple LCCNs or VIAFs SELECT DISTINCT ?academic ?academicLabel ?academicDescription ?academicAltLabel (GROUP_CONCAT(DISTINCT ?lccnurl; SEPARATOR = ";") AS ?LCCN_urls) (GROUP_CONCAT(DISTINCT ?viafurl; SEPARATOR = ";") AS ?VIAF_urls) WHERE { {
SELECT ?academic (COUNT(DISTINCT ?lccn2) AS ?countl) (COUNT(DISTINCT ?viaf2) AS ?countv) WHERE { ?academic wdt:P31 wd:Q5 . # academic is a person { ?academic wdt:P27 wd:Q664 . # citizen of New Zealand } UNION { ?academic wdt:P551 wd:Q664 . # residence of New Zealand } ?academic wdt:P244 ?lccn2 . ?academic wdt:P214 ?viaf2 } GROUP BY ?academic } FILTER ( ?countv > 1|| ?count1 > 1 )

OPTIONAL { ?academic wdt:P244 ?lccn . BIND( IRI(CONCAT('https://lccn.loc.gov/', STR(?lccn))) AS ?lccnurl ) . } . OPTIONAL { ?academic wdt:P214 ?viaf . BIND( IRI(CONCAT('https://viaf.org/viaf/', STR(?viaf))) AS ?viafurl ) . } . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" } } GROUP BY ?academic ?academicLabel ?academicDescription ?academicAltLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Find people with multiple LCCNs or VIAFs
SELECT DISTINCT 
   ?academic 
   ?academicLabel 
   ?academicDescription 
   ?academicAltLabel 
   (GROUP_CONCAT(DISTINCT ?lccnurl; SEPARATOR = ";") AS ?LCCN_urls)
   (GROUP_CONCAT(DISTINCT ?viafurl; SEPARATOR = ";") AS ?VIAF_urls)
   WHERE {
     {   
       SELECT ?academic (COUNT(DISTINCT ?lccn2) AS ?countl) (COUNT(DISTINCT ?viaf2) AS ?countv) WHERE {
           ?academic wdt:P31 wd:Q5 . # academic is a person
           {
              ?academic wdt:P27 wd:Q664 .  # citizen of New Zealand
           } UNION {
              ?academic wdt:P551 wd:Q664 .  # residence of New Zealand
           } 
          ?academic wdt:P244 ?lccn2 . 
          ?academic wdt:P214 ?viaf2
        } GROUP BY ?academic 
     }
   FILTER ( ?countv > 1||  ?count1 > 1 )

   OPTIONAL { ?academic wdt:P244 ?lccn .  BIND( IRI(CONCAT('https://lccn.loc.gov/', STR(?lccn)))  AS ?lccnurl ) .   } . 
   OPTIONAL { ?academic wdt:P214 ?viaf .  BIND( IRI(CONCAT('https://viaf.org/viaf/', STR(?viaf)))  AS ?viafurl ) . } . 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" }
}
GROUP BY ?academic  ?academicLabel   ?academicDescription   ?academicAltLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?LCCN_urls") v12("?VIAF_urls") v3("?academic"):::projected v2("?count1") v6("?countl") v7("?countv") v7("?lccn") v4("?lccn2") v8("?lccnurl"):::projected v9("?viaf") v5("?viaf2") v10("?viafurl"):::projected c5(["wd:Q664"]):::iri c10(["bd:serviceParam"]):::iri c3(["wd:Q5"]):::iri c12(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal f0[["(?countv > '1^^xsd:integer' || ?count1 > '1^^xsd:integer')"]] f0 --> v7 f0 --> v2 v3 --"wdt:P31"--> c3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P551"--> c5 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P27"--> c5 end union0r <== or ==> union0l end v3 --"wdt:P244"--> v4 v3 --"wdt:P214"--> v5 bind3[/"count(?lccn2)"/] v4 --o bind3 bind3 --as--o v6 bind4[/"count(?viaf2)"/] v5 --o bind4 bind4 --as--o v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P244".-> v7 bind5[/"concat('https://lccn.loc.gov/',str(?lccn))"/] v7 --o bind5 bind5 --as--o v8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P214".-> v9 bind6[/"concat('https://viaf.org/viaf/',str(?viaf))"/] v9 --o bind6 bind6 --as--o v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind9[/"?lccnurl"/] v8 --o bind9 bind9 --as--o v11 bind10[/"?viafurl"/] v10 --o bind10 bind10 --as--o v12