query-2b1ae0dfff63bf167ea1bb602d68f02b
Anyway, this is it: .Q131016#P2284Some currencies don't use the same conversion system (if any), like Your query is not bound to a specific time, some companies have multiple revenues per multiple dates (I'm not sure whether ranks should be applied). .nowhere in the database suggests looking for a special "best" rank, it's documentation-like ones. These ones do not support "choose best value" strategy. Although the p: predicate and use wdt:I have to leave the simple Quite complicated but is at least partly possible. The most notable problems are: (facepalm) Then finally:
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?revenue ?unitLabel ?hqLabel ?revenue_USD ?date WHERE {
?item wdt:P31 wd:Q4830453;
p:P2139 ?statement .
OPTIONAL { ?item wdt:P159 ?hq } .
?statement wikibase:rank ?rank .
FILTER( ?rank != wikibase:DeprecatedRank ) .
OPTIONAL {
FILTER( ?rank != wikibase:PreferredRank ) .
?item p:P2139 ?statement1 .
?statement1 wikibase:rank wikibase:PreferredRank .
FILTER( ?statement1 != ?statement ) .
} .
FILTER( !BOUND( ?statement1 ) ) .
OPTIONAL { ?statement pq:P585 ?date } .
{
?statement psv:P2139 [
wikibase:quantityAmount ?revenue; wikibase:quantityUnit wd:Q4917
] .
BIND( wd:Q4917 AS ?unit ) .
BIND( ?revenue AS ?revenue_USD ) .
} UNION {
?statement psv:P2139 [
wikibase:quantityAmount ?revenue; wikibase:quantityUnit ?unit
] .
FILTER( ?unit != wd:Q4917 ) .
?unit p:P2284 ?unit_statement .
?unit_statement wikibase:rank ?unit_rank;
psv:P2284 [ wikibase:quantityUnit wd:Q4917; wikibase:quantityAmount ?usd ] .
FILTER( ?unit_rank != wikibase:DeprecatedRank ) .
OPTIONAL {
FILTER( ?unit_rank != wikibase:PreferredRank ) .
?unit p:P2284 ?unit_statement1 .
?unit_statement1 psv:P2284/wikibase:quantityUnit wd:Q4917;
wikibase:rank wikibase:PreferredRank .
FILTER( ?unit_statement1 != ?unit_statement ) .
} .
FILTER( !BOUND( ?unit_statement1 ) ) .
BIND( ?revenue * ?usd AS ?revenue_USD ) .
} .
SERVICE wikibase:label { bd:serviceParam wikibase:language "cs,en" } .
}
ORDER BY DESC(?revenue_USD)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?date"):::projected
v6("?hq")
v5("?item"):::projected
v3("?rank")
v8("?revenue"):::projected
v14("?revenue_USD"):::projected
v4("?statement")
v2("?statement1")
v9("?unit")
v11("?unit_rank")
v12("?unit_statement")
v10("?unit_statement1")
v13("?usd")
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c11(["wd:Q4917"]):::iri
c2(["wikibase:PreferredRank"]):::iri
c4(["wd:Q4830453"]):::iri
c18(["cs,en"]):::literal
c16(["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
v4 --"wikibase:rank"--> v3
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P2139".-> v2
v2 --"wikibase:rank"--> c2
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:qualifier/P585".-> v7
end
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f2[["not bound(?unit_statement1)"]]
f2 --> v10
f3[["?unit_rank != 'wikibase:DeprecatedRank'"]]
f3 --> v11
f4[["?unit != 'wd:Q4917'"]]
f4 --> v9
a2 --"wikibase:quantityAmount"--> v8
a2 --"wikibase:quantityUnit"--> v9
v4 --"p:statement/value/P2139"--> a2
v9 --"p:P2284"--> v12
v12 --"wikibase:rank"--> v11
a3 --"wikibase:quantityUnit"--> c11
a3 --"wikibase:quantityAmount"--> v13
v12 --"p:statement/value/P2284"--> a3
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v9 -."p:P2284".-> v10
v10 --"p:statement/value/P2284"--> a4
a4 --"wikibase:quantityUnit"--> c11
v10 --"wikibase:rank"--> c2
end
bind5[/"?revenue * ?usd"/]
v8 --o bind5
v13 --o bind5
bind5 --as--o v14
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
a1 --"wikibase:quantityAmount"--> v8
a1 --"wikibase:quantityUnit"--> c11
v4 --"p:statement/value/P2139"--> a1
bind6[/"'wd:Q4917'"/]
bind6 --as--o v9
bind7[/"?revenue"/]
v8 --o bind7
bind7 --as--o v14
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c16 --"wikibase:language"--> c18
end