SPARQL examples: Difference between revisions

(add query with AKF data)
(add query for companies with official names and time ranges)
Line 1: Line 1:
== Companies with labels, ISINs and WKNs ==
== Companies ==
 
=== Companies with labels, ISINs and WKNs ===


{{SPARQL|query=
{{SPARQL|query=
Line 11: Line 13:
}
}
}}
}}
{{SPARQL|query=
#Companies with official names and time ranges for them
SELECT DISTINCT ?company ?official_name (year(?start_time) as ?start_year) (year(?end_time) as ?end_year) WHERE {
  ?company wdt:P325 wd:Q1.
  ?company p:P346 [ ps:P346 ?official_name; pq:P79 ?start_time ; pq:P76 ?end_time ]
}
}}
== Entities ==


=== Entities with labels  ===
=== Entities with labels  ===
Line 21: Line 34:
}
}
}}
}}
== Properties ==


=== Properties with labels, aliases, descriptions and datatypes  ===
=== Properties with labels, aliases, descriptions and datatypes  ===

Revision as of 07:15, 3 April 2023

Companies

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")
}
#Companies with official names and time ranges for them
SELECT DISTINCT ?company ?official_name (year(?start_time) as ?start_year) (year(?end_time) as ?end_year) WHERE {
  ?company wdt:P325 wd:Q1.
  ?company p:P346 [ ps:P346 ?official_name; pq:P79 ?start_time ; pq:P76 ?end_time ]

}

Entities

Entities with labels

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

Properties

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")
}