query-df8c06983ea79e54817ccda05f7ec47f
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 rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select distinct ?item ?revenue ?unitLabel ?usd ?revenue_USD where {
?item wdt:P31 wd:Q5 ;
wdt:P21 wd:Q6581072 ;
p:P2218 ?s .
?s rdf:type wikibase:BestRank .
{
?s psv:P2218 [
wikibase:quantityAmount ?revenue; wikibase:quantityUnit wd:Q4917
] .
BIND( wd:Q4917 AS ?unit ) .
BIND( ?revenue AS ?revenue_USD ) .
BIND (1 AS ?usd)
} UNION {
?s psv:P2218 [
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 "[AUTO_LANGUAGE],en". }
filter (?revenue_USD >= 1000000000)
}
order by desc (?revenue_USD)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?item"):::projected
v4("?revenue"):::projected
v10("?revenue_USD"):::projected
v3("?s")
v5("?unit")
v8("?unit_rank")
v9("?unit_statement")
v7("?unit_statement1")
v6("?usd"):::projected
a1((" "))
a2((" "))
a3((" "))
a4((" "))
c11(["wd:Q4917"]):::iri
c14(["wikibase:PreferredRank"]):::iri
c8(["wikibase:BestRank"]):::iri
c5(["wd:Q6581072"]):::iri
c19(["bd:serviceParam"]):::iri
c3(["wd:Q5"]):::iri
c21(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?revenue_USD >= '1000000000^^xsd:integer'"]]
f0 --> v10
v2 --"p:direct/P31"--> c3
v2 --"p:direct/P21"--> c5
v2 --"p:P2218"--> v3
v3 --"a"--> c8
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f1[["not bound(?unit_statement1)"]]
f1 --> v7
f2[["?unit_rank != 'wikibase:DeprecatedRank'"]]
f2 --> v8
f3[["?unit != 'wd:Q4917'"]]
f3 --> v5
a2 --"wikibase:quantityAmount"--> v4
a2 --"wikibase:quantityUnit"--> v5
v3 --"p:statement/value/P2218"--> a2
v5 --"p:P2284"--> v9
v9 --"wikibase:rank"--> v8
a3 --"wikibase:quantityUnit"--> c11
a3 --"wikibase:quantityAmount"--> v6
v9 --"p:statement/value/P2284"--> a3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:P2284".-> v7
v7 --"p:statement/value/P2284"--> a4
a4 --"wikibase:quantityUnit"--> c11
v7 --"wikibase:rank"--> c14
end
bind4[/"?revenue * ?usd"/]
v4 --o bind4
v6 --o bind4
bind4 --as--o v10
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
a1 --"wikibase:quantityAmount"--> v4
a1 --"wikibase:quantityUnit"--> c11
v3 --"p:statement/value/P2218"--> a1
bind5[/"'wd:Q4917'"/]
bind5 --as--o v5
bind6[/"?revenue"/]
v4 --o bind6
bind6 --as--o v10
bind7[/"'1^^xsd:integer'"/]
bind7 --as--o v6
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c19 --"wikibase:language"--> c21
end