query-32249438fa5ef09a7cb5c00b554c7ac8
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/> SELECT ?item ?itemLabel (GROUP_CONCAT(DISTINCT ?counLabel; SEPARATOR=", ") AS ?countries) (GROUP_CONCAT(DISTINCT ?hqLabel; SEPARATOR=", ") AS ?hqs) ?revenue ?revenue_USD ?unitLabel ?date
WHERE {
?item wdt:P31 wd:Q4830453.
?item p:P2139 ?statement.
OPTIONAL { ?item wdt:P159 ?hq. }
OPTIONAL { ?item wdt:P17 ?coun. }
?statement wikibase:rank ?rank.
OPTIONAL {
?item p:P2139 ?statement1.
?statement1 wikibase:rank wikibase:PreferredRank.
FILTER(?rank != wikibase:PreferredRank)
FILTER(?statement1 != ?statement)
}
OPTIONAL { ?statement pq:P585 ?date. }
{
?statement psv:P2139 _:b9.
_:b9 wikibase:quantityAmount ?revenue.
_:b9 wikibase:quantityUnit wd:Q4917.
BIND(wd:Q4917 AS ?unit)
BIND(?revenue AS ?revenue_USD)
}
UNION
{
?statement psv:P2139 _:b10.
_:b10 wikibase:quantityAmount ?revenue.
_:b10 wikibase:quantityUnit ?unit.
?unit p:P2284 ?unit_statement.
?unit_statement wikibase:rank ?unit_rank.
?unit_statement psv:P2284 _:b11.
_:b11 wikibase:quantityUnit wd:Q4917.
_:b11 wikibase:quantityAmount ?usd.
OPTIONAL {
?unit p:P2284 ?unit_statement1.
?unit_statement1 (psv:P2284/wikibase:quantityUnit) wd:Q4917.
?unit_statement1 wikibase:rank wikibase:PreferredRank.
FILTER(?unit_rank != wikibase:PreferredRank)
FILTER(?unit_statement1 != ?unit_statement)
}
BIND(?revenue * ?usd AS ?revenue_USD)
FILTER(?unit != wd:Q4917)
FILTER(?unit_rank != wikibase:DeprecatedRank)
FILTER(!BOUND(?unit_statement1))
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
FILTER(?rank != wikibase:DeprecatedRank)
FILTER(!BOUND(?statement1))
}
GROUP BY ?item ?itemLabel ?revenue ?revenue_USD ?unitLabel ?date
ORDER BY DESC(?revenue_USD)
LIMIT 10
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?coun")
v15("?counLabel"):::projected
v17("?countries")
v8("?date"):::projected
v6("?hq")
v16("?hqLabel"):::projected
v18("?hqs")
v5("?item"):::projected
v3("?rank")
v9("?revenue"):::projected
v15("?revenue_USD"):::projected
v4("?statement")
v2("?statement1")
v10("?unit")
v12("?unit_rank")
v13("?unit_statement")
v11("?unit_statement1")
v14("?usd")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c13(["wd:Q4917"]):::iri
c2(["wikibase:PreferredRank"]):::iri
c4(["wd:Q4830453"]):::iri
c19(["en"]):::literal
c17(["bd:serviceParam"]):::iri
f0[["not bound(?statement1)"]]
f0 --> v2
f1[["?rank != 'wikibase:DeprecatedRank'"]]
f1 --> v3
v5 --"p:direct/P31"--> c4
v5 --"p:P2139"--> v4
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P159".-> v6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P17".-> v7
end
v4 --"wikibase:rank"--> v3
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P2139".-> v2
v2 --"wikibase:rank"--> c2
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P585".-> v8
end
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f2[["not bound(?unit_statement1)"]]
f2 --> v11
f3[["?unit_rank != 'wikibase:DeprecatedRank'"]]
f3 --> v12
f4[["?unit != 'wd:Q4917'"]]
f4 --> v10
v4 --"p:statement/value/P2139"--> a2
a2 --"wikibase:quantityAmount"--> v9
a2 --"wikibase:quantityUnit"--> v10
v10 --"p:P2284"--> v13
v13 --"wikibase:rank"--> v12
v13 --"p:statement/value/P2284"--> a3
a3 --"wikibase:quantityUnit"--> c13
a3 --"wikibase:quantityAmount"--> v14
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v10 -."p:P2284".-> v11
v11 --"p:statement/value/P2284"--> a4
a4 --"wikibase:quantityUnit"--> c13
v11 --"wikibase:rank"--> c2
end
bind5[/"?revenue * ?usd"/]
v9 --o bind5
v14 --o bind5
bind5 --as--o v15
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:statement/value/P2139"--> a1
a1 --"wikibase:quantityAmount"--> v9
a1 --"wikibase:quantityUnit"--> c13
bind6[/"'wd:Q4917'"/]
bind6 --as--o v10
bind7[/"?revenue"/]
v9 --o bind7
bind7 --as--o v15
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
end
bind10[/"?counLabel"/]
v15 --o bind10
bind10 --as--o v17
bind11[/"?hqLabel"/]
v16 --o bind11
bind11 --as--o v18