Project:SPARQL/examples

From ASCLTestWikibase
Jump to navigation Jump to search

Voorbeelden

The queries on this page will be displayed in the Examples dropdown at https://ascltestwikibase.wikibase.cloud/query/

Overview of items (Qs) in this Wikibase, with their Labels, Descriptions and Aliases, both in SW and in EN, as well their equivalent Q-items en URIs in Wikidata (if applicable)

# Overview of items (Qs) in this Wikibase, 
# with their Labels, Descriptions and Aliases, 
# both in SW and in EN, 
# as well their equivalent Q-items en URIs in Wikidata (if applicable) 

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <https://ascltestwikibase.wikibase.cloud/prop/direct/>

SELECT DISTINCT ?item ?itemLabelSW ?itemLabelEN 
?itemDescriptionSW ?itemDescriptionEN 
(GROUP_CONCAT(DISTINCT ?itemAliasSW ; separator = "|") as ?itemAliasesSW )
(GROUP_CONCAT(DISTINCT ?itemAliasEN ; separator = "|") as ?itemAliasesEN )
?wikidataEquivalentURI ?wikidataEquivalentItem 

WHERE 
{
  ?item wikibase:identifiers ?b
  OPTIONAL{?item wdt:P1 ?wikidataEquivalentURI.} 
  OPTIONAL{?item wdt:P3 ?wikidataEquivalentItem.} 

  OPTIONAL{?item rdfs:label ?itemLabelSW FILTER(LANG(?itemLabelSW)='sw').}
  OPTIONAL{?item rdfs:label ?itemLabelEN FILTER(LANG(?itemLabelEN)='en').}
  
  OPTIONAL{?item schema:description ?itemDescriptionSW FILTER(LANG(?itemDescriptionSW) = "sw"). }  
  OPTIONAL{?item schema:description ?itemDescriptionEN FILTER(LANG(?itemDescriptionEN) = "en"). }
  
  OPTIONAL{?item skos:altLabel ?itemAliasSW FILTER(LANG(?itemAliasSW) = "sw"). }  
  OPTIONAL{?item skos:altLabel ?itemAliasEN FILTER(LANG(?itemAliasEN) = "en"). }     
    
}
GROUP BY ?item ?itemLabelSW ?itemLabelEN ?itemDescriptionSW ?itemDescriptionEN ?wikidataEquivalentURI ?wikidataEquivalentItem  
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))

Try it!