SPARQL examples: Difference between revisions
From Handbuch der Deutschen Aktiengesellschaften
(Blanked the page) Tags: Blanking Reverted |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== Companies == | |||
=== Companies with company names for different years === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?company ?companyLabel ?companyNames ?YearName WHERE { | |||
?company rdfs:label ?companyLabel; | |||
wdt:P31 wd:Q1. | |||
FILTER((LANG(?companyLabel)) = "de") | |||
OPTIONAL { ?company wdt:P6 ?companyNames. } | |||
OPTIONAL { | |||
?company p:P6 ?statement. | |||
?statement pq:P4 ?YearName. | |||
} | |||
} | |||
}} | |||
=== Companies and their industries with time ranges === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?company ?companyLabel ?industry ?industryStartDate ?industryEndDate WHERE { | |||
?company rdfs:label ?companyLabel; | |||
wdt:P31 wd:Q1. | |||
FILTER((LANG(?companyLabel)) = "de") | |||
OPTIONAL { ?company wdt:P16 ?industry. } | |||
OPTIONAL { | |||
?company p:P16 ?industryStatement. | |||
?industryStatement pq:P29 ?industryStartDate; | |||
pq:P30 ?industryEndDate. | |||
} | |||
} | |||
}} | |||
=== Companies and their industries with time ranges and URL links to the digitised sources === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?company ?companyLabel ?industry ?industryStartDate ?industryEndDate ?reference WHERE { | |||
?company rdfs:label ?companyLabel; | |||
wdt:P31 wd:Q1. | |||
FILTER((LANG(?companyLabel)) = "de") | |||
OPTIONAL { ?company wdt:P16 ?industry. } | |||
OPTIONAL { | |||
?company p:P16 ?industryStatement. | |||
?industryStatement pq:P29 ?industryStartDate; | |||
pq:P30 ?industryEndDate. | |||
OPTIONAL { ?industryStatement (prov:wasDerivedFrom/pr:P10) ?reference. } | |||
} | |||
} | |||
}} | |||
=== Map with headquarters of companies === | |||
{{SPARQL|query= | |||
#defaultView:Map | |||
SELECT DISTINCT ?item ?itemLabel ?city ?cityLabel ?geo WHERE { | |||
?item wdt:P31 wd:Q1; | |||
wdt:P32 ?city. | |||
?city wdt:P31 wd:Q4; | |||
wdt:P28 ?geo. | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "de". } | |||
} | |||
}} | |||
== Entities == | |||
=== Entities with labels === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?entity ?entityLabel WHERE { | |||
?entity rdfs:label ?entityLabel. | |||
FILTER((LANG(?entityLabel)) = "en") | |||
} | |||
}} | |||
== Properties == | |||
=== 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:description ?propertyDescription; | |||
rdfs:label ?propertyLabel. | |||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | |||
} | |||
}} | |||
=== Properties with non-capitalized labels and their datatypes === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE { | |||
?propertyWikibase wikibase:directClaim ?p; | |||
wikibase:propertyType ?propertyType; | |||
rdfs:label ?propertyLabel. | |||
FILTER(REGEX(?propertyLabel, "[a-z].+")) | |||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | |||
} | |||
}} | |||
=== Properties with capitalized labels and their datatypes === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE { | |||
?propertyWikibase wikibase:directClaim ?p; | |||
wikibase:propertyType ?propertyType; | |||
rdfs:label ?propertyLabel. | |||
FILTER(!REGEX(?propertyLabel, "[a-z].+")) | |||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | |||
} | |||
}} |
Latest revision as of 14:31, 27 August 2024
Companies
Companies with company names for different years
SELECT DISTINCT ?company ?companyLabel ?companyNames ?YearName WHERE {
?company rdfs:label ?companyLabel;
wdt:P31 wd:Q1.
FILTER((LANG(?companyLabel)) = "de")
OPTIONAL { ?company wdt:P6 ?companyNames. }
OPTIONAL {
?company p:P6 ?statement.
?statement pq:P4 ?YearName.
}
}
Companies and their industries with time ranges
SELECT DISTINCT ?company ?companyLabel ?industry ?industryStartDate ?industryEndDate WHERE {
?company rdfs:label ?companyLabel;
wdt:P31 wd:Q1.
FILTER((LANG(?companyLabel)) = "de")
OPTIONAL { ?company wdt:P16 ?industry. }
OPTIONAL {
?company p:P16 ?industryStatement.
?industryStatement pq:P29 ?industryStartDate;
pq:P30 ?industryEndDate.
}
}
Companies and their industries with time ranges and URL links to the digitised sources
SELECT DISTINCT ?company ?companyLabel ?industry ?industryStartDate ?industryEndDate ?reference WHERE {
?company rdfs:label ?companyLabel;
wdt:P31 wd:Q1.
FILTER((LANG(?companyLabel)) = "de")
OPTIONAL { ?company wdt:P16 ?industry. }
OPTIONAL {
?company p:P16 ?industryStatement.
?industryStatement pq:P29 ?industryStartDate;
pq:P30 ?industryEndDate.
OPTIONAL { ?industryStatement (prov:wasDerivedFrom/pr:P10) ?reference. }
}
}
Map with headquarters of companies
#defaultView:Map
SELECT DISTINCT ?item ?itemLabel ?city ?cityLabel ?geo WHERE {
?item wdt:P31 wd:Q1;
wdt:P32 ?city.
?city wdt:P31 wd:Q4;
wdt:P28 ?geo.
SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
Entities
Entities with labels
SELECT DISTINCT ?entity ?entityLabel WHERE {
?entity rdfs:label ?entityLabel.
FILTER((LANG(?entityLabel)) = "en")
}
Properties
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.
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}
Properties with non-capitalized labels and their datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE {
?propertyWikibase wikibase:directClaim ?p;
wikibase:propertyType ?propertyType;
rdfs:label ?propertyLabel.
FILTER(REGEX(?propertyLabel, "[a-z].+"))
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}
Properties with capitalized labels and their datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE {
?propertyWikibase wikibase:directClaim ?p;
wikibase:propertyType ?propertyType;
rdfs:label ?propertyLabel.
FILTER(!REGEX(?propertyLabel, "[a-z].+"))
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}