Project:SPARQL/examples: Difference between revisions

no edit summary
No edit summary
Line 191: Line 191:
}
}
</sparql>
</sparql>


===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===
===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===
Line 274: Line 272:
}
}
ORDER BY ?date
ORDER BY ?date
</sparql>
===People sorted by the number of places they lived, including the number of cites/towns/villages they lived in===
<sparql tryit="1">
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
SELECT ?person ?personLabel (count(?resided) as ?residence_count) (count(distinct ?resided) as ?residence_distinct) WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
  ?person bnp:P29/bnps:P29 ?resided.
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
} group by ?person ?personLabel ?statements order by desc(?residence_count)
# Credit to @Tagishsimon for helping me figure out the counting logic here
</sparql>
</sparql>
6,317

edits