I'm trying to get some company data from wikidata but for some reason it doesn't work for companies as "Groupe La Poste" or "Google"
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT
?company ?alternative ?companyLabel ?isin ?web ?country ?countryLabel ?inception ?employees ?employeesDate ?hq ?hqLabel ?countryHq ?countryHqLabel
WHERE
{
?article schema:inLanguage "en" .
?article schema:isPartOf <https://en.wikipedia.org/>.
?article schema:about ?company .
?company p:P31/ps:P31/wdt:P279 wd:Q4830453.
?company wdt:P946 ?isin.
?company rdfs:label "Groupe La Poste"@en.
OPTIONAL {?company wdt:P856 ?web.}
OPTIONAL {?company wdt:P571 ?inception.}
OPTIONAL {?company wdt:P17 ?country.}
OPTIONAL {?company p:P1128 ?employeesStatement.}
OPTIONAL {?employeesStatement ps:P1128 ?employees.}
OPTIONAL {?employeesStatement pq:P585 ?employeesDate.}
FILTER NOT EXISTS {
?employeesStatement pq:585 ?employeesDate1
FILTER (?employeesDate1 > ?employeesDate)
}
OPTIONAL {?company wdt:P159 ?hq.}
OPTIONAL {?hq wdt:P17 ?countryHq.}
OPTIONAL {?company skos:altLabel ?alternative.
FILTER (LANG (?alternative) = "en")}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Also, for companies as Ubisoft, I don't get the last employees date, I get 2 of them. I'm almost new in all this. What am I doing wrong?
UPDATE 1: I added the * after the subclass chain and I put all what's related to the ?employeesDate in a single OPTIONAL.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT
?company ?alternative ?companyLabel ?isin ?web ?country ?countryLabel ?inception ?employees ?employeesDate ?hq ?hqLabel ?countryHq ?countryHqLabel
WHERE
{
?article schema:inLanguage "en" .
?article schema:isPartOf <https://en.wikipedia.org/>.
?article schema:about ?company .
?company p:P31/ps:P31/wdt:P279* wd:Q4830453.
?company rdfs:label "Groupe La Poste"@en.
OPTIONAL {?company wdt:P946 ?isin.}
OPTIONAL {?company wdt:P856 ?web.}
OPTIONAL {?company wdt:P571 ?inception.}
OPTIONAL {?company wdt:P17 ?country.}
OPTIONAL {?company p:P1128 ?employeesStatement.
?employeesStatement ps:P1128 ?employees.
?employeesStatement pq:P585 ?employeesDate. }
FILTER NOT EXISTS { ?company pq:P585 ?otherEmployeesDate FILTER (?otherEmployeesDate > ?employeesDate) }
OPTIONAL {?company wdt:P159 ?hq.}
OPTIONAL {?hq wdt:P17 ?countryHq.}
OPTIONAL {?company skos:altLabel ?alternative.
FILTER (LANG (?alternative) = "en")}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}