SPARQL examples: Difference between revisions

(Created page with "== Items == === Entities with labels === {{SPARQL|query= SELECT DISTINCT ?entity ?entityLabel WHERE { ?entity rdfs:label ?entityLabel. FILTER((LANG(?entityLabel)) = "en") } }} === Properties with labels, aliases, descriptions and datatypes === {{SPARQL|query= SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE { ?propertyWikibase wikibase:directClaim ?p; wikibase:propertyType ?propertyType; schema:d...")
 
(add query with AKF data)
Line 1: Line 1:
== Items ==
== Companies with labels, ISINs and WKNs ==
 
{{SPARQL|query=
#Companies with labels, ISINs and WKNs
SELECT DISTINCT ?company ?companyLabel ?ISIN ?WKN WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P325 wd:Q1.
  OPTIONAL { ?company wdt:P127 ?ISIN. }
  OPTIONAL { ?company wdt:P4 ?WKN. }
  FILTER((LANG(?companyLabel)) = "de")
}
}}


=== Entities with labels  ===
=== Entities with labels  ===


{{SPARQL|query=
{{SPARQL|query=
# Entities with labels
SELECT DISTINCT ?entity ?entityLabel WHERE {
SELECT DISTINCT ?entity ?entityLabel WHERE {
   ?entity rdfs:label ?entityLabel.
   ?entity rdfs:label ?entityLabel.
Line 13: Line 25:


{{SPARQL|query=
{{SPARQL|query=
# Properties with labels, aliases, descriptions and datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE {
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE {
   ?propertyWikibase wikibase:directClaim ?p;
   ?propertyWikibase wikibase:directClaim ?p;

Revision as of 07:03, 3 April 2023

Companies with labels, ISINs and WKNs

#Companies with labels, ISINs and WKNs
SELECT DISTINCT ?company ?companyLabel ?ISIN ?WKN WHERE {
  ?company rdfs:label ?companyLabel;
    wdt:P325 wd:Q1.
  OPTIONAL { ?company wdt:P127 ?ISIN. }
  OPTIONAL { ?company wdt:P4 ?WKN. }
  FILTER((LANG(?companyLabel)) = "de")
}

Entities with labels

# Entities with labels
SELECT DISTINCT ?entity ?entityLabel WHERE {
  ?entity rdfs:label ?entityLabel.
  FILTER((LANG(?entityLabel)) = "en")
}

Properties with labels, aliases, descriptions and datatypes

# Properties with labels, aliases, descriptions and datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE {
  ?propertyWikibase wikibase:directClaim ?p;
    wikibase:propertyType ?propertyType;
    schema:description ?propertyDescription;
    rdfs:label ?propertyLabel.
  FILTER((LANG(?propertyLabel)) = "en")
  FILTER((LANG(?propertyDescription)) = "en")
  OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
  FILTER((LANG(?propertyAlias)) = "en")
}