SPARQL Examples: Difference between revisions

From Riga Literata
Jump to navigation Jump to search
(Blanked the page)
Tags: Blanking Manual revert
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== All persons with all properties ==
<sparql tryit="1">
PREFIX rlwd: <https://riga-literata.wikibase.cloud/entity/>
PREFIX rlwdt: <https://riga-literata.wikibase.cloud/prop/direct/>


SELECT ?person ?personLabel
(GROUP_CONCAT(DISTINCT ?genderLabel; SEPARATOR="; ") AS ?gender)
(GROUP_CONCAT(DISTINCT ?birthdate; SEPARATOR="; ") AS ?birthdates)
(GROUP_CONCAT(DISTINCT ?birthplaceLabel; SEPARATOR="; ") AS ?birthplace)
(GROUP_CONCAT(DISTINCT ?deathdate; SEPARATOR="; ") AS ?deathdates)
(GROUP_CONCAT(DISTINCT ?deathplaceLabel; SEPARATOR="; ") AS ?deathplace)
(GROUP_CONCAT(DISTINCT ?worklocationLabel; SEPARATOR="; ") AS ?worklocation)
(GROUP_CONCAT(DISTINCT ?wdq; SEPARATOR="; ") AS ?wdq_id)
(GROUP_CONCAT(DISTINCT ?viaf; SEPARATOR="; ") AS ?viaf_id)
(GROUP_CONCAT(DISTINCT ?lnc10; SEPARATOR="; ") AS ?lnc10_id)
WHERE {
  ?person rlwdt:P1 rlwd:Q6 ;
          OPTIONAL { ?person rlwdt:P15 ?gender.}
          OPTIONAL { ?person rlwdt:P18 ?birthdate.}
          OPTIONAL { ?person rlwdt:P20 ?birthplace.}
          OPTIONAL { ?person rlwdt:P19 ?deathdate.}
          OPTIONAL { ?person rlwdt:P21 ?deathplace.}
          OPTIONAL { ?person rlwdt:P31 ?worklocation.}
          OPTIONAL { ?person rlwdt:P6 ?wdq.}
          OPTIONAL { ?person rlwdt:P30 ?viaf.}
          OPTIONAL { ?person rlwdt:P4 ?lnc10.}
 
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]" .
    ?person rdfs:label ?personLabel .
    ?gender rdfs:label ?genderLabel .
    ?birthplace rdfs:label ?birthplaceLabel .
    ?deathplace rdfs:label ?deathplaceLabel .
    ?worklocation rdfs:label ?worklocationLabel .
  }
}
GROUP BY ?person ?personLabel
ORDER BY ?personLabel
</sparql>

Latest revision as of 08:29, 9 February 2023

All persons with all properties

PREFIX rlwd: <https://riga-literata.wikibase.cloud/entity/>
PREFIX rlwdt: <https://riga-literata.wikibase.cloud/prop/direct/>

SELECT ?person ?personLabel
(GROUP_CONCAT(DISTINCT ?genderLabel; SEPARATOR="; ") AS ?gender)
(GROUP_CONCAT(DISTINCT ?birthdate; SEPARATOR="; ") AS ?birthdates)
(GROUP_CONCAT(DISTINCT ?birthplaceLabel; SEPARATOR="; ") AS ?birthplace)
(GROUP_CONCAT(DISTINCT ?deathdate; SEPARATOR="; ") AS ?deathdates)
(GROUP_CONCAT(DISTINCT ?deathplaceLabel; SEPARATOR="; ") AS ?deathplace)
(GROUP_CONCAT(DISTINCT ?worklocationLabel; SEPARATOR="; ") AS ?worklocation)
(GROUP_CONCAT(DISTINCT ?wdq; SEPARATOR="; ") AS ?wdq_id)
(GROUP_CONCAT(DISTINCT ?viaf; SEPARATOR="; ") AS ?viaf_id)
(GROUP_CONCAT(DISTINCT ?lnc10; SEPARATOR="; ") AS ?lnc10_id)
WHERE {

  ?person rlwdt:P1 rlwd:Q6 ;
          OPTIONAL { ?person rlwdt:P15 ?gender.}
          OPTIONAL { ?person rlwdt:P18 ?birthdate.}
          OPTIONAL { ?person rlwdt:P20 ?birthplace.}
          OPTIONAL { ?person rlwdt:P19 ?deathdate.}
          OPTIONAL { ?person rlwdt:P21 ?deathplace.}
          OPTIONAL { ?person rlwdt:P31 ?worklocation.}
          OPTIONAL { ?person rlwdt:P6 ?wdq.}
          OPTIONAL { ?person rlwdt:P30 ?viaf.}
          OPTIONAL { ?person rlwdt:P4 ?lnc10.}
  
  SERVICE wikibase:label { 
    bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]" .
    ?person rdfs:label ?personLabel .
    ?gender rdfs:label ?genderLabel .
    ?birthplace rdfs:label ?birthplaceLabel .
    ?deathplace rdfs:label ?deathplaceLabel .
    ?worklocation rdfs:label ?worklocationLabel .
  }

} 
GROUP BY ?person ?personLabel
ORDER BY ?personLabel

Try it!