query-0d203ad981f2e5092f79645e45f545d0

rq turtle/ttl

Values with specific unitHi, I have this query:

Use at

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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?revenue ?hq ?date ?profit (ROUND(?profmar*1000)/100 AS ?profmar_rounded) ?unit
WHERE
{
    ?item wdt:P31 wd:Q4830453 .
    ?item wdt:P159 ?hq . 
    ?hq wdt:P17 wd:Q213 .
    ?item p:P2139 ?revenueSt .
    ?revenueSt a wikibase:BestRank; ps:P2139 ?revenue .
    OPTIONAL { ?revenueSt psv:P2139 ?psv .
              ?psv wikibase:quantityUnit ?unit }. 
    OPTIONAL { ?revenueSt pq:P585 ?date } .
    ?item p:P2295 ?profSt .
    ?profSt a wikibase:BestRank; ps:P2295 ?profit .
    BIND(?revenue / ?profit AS ?profmar) .
    FILTER(?profmar>0)
    FILTER( ?item not in (wd:Q100707321,wd:Q12021780))
}
ORDER BY ASC(?profmar)
LIMIT 20

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?date"):::projected v3("?hq"):::projected v2("?item"):::projected v9("?profSt") v10("?profit"):::projected v11("?profmar"):::projected v11("?profmar_rounded") v6("?psv") v5("?revenue"):::projected v4("?revenueSt") v7("?unit"):::projected c5(["wd:Q4830453"]):::iri c11(["wikibase:BestRank"]):::iri c8(["wd:Q213"]):::iri f0[["?item != 'wd:Q100707321'?item != 'wd:Q12021780'"]] f0 --> v2 f1[["?profmar > '0^^xsd:integer'"]] f1 --> v11 v2 --"p:direct/P31"--> c5 v2 --"p:direct/P159"--> v3 v3 --"p:direct/P17"--> c8 v2 --"p:P2139"--> v4 v4 --"a"--> c11 v4 --"p:statement/P2139"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:statement/value/P2139".-> v6 v6 --"wikibase:quantityUnit"--> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P585".-> v8 end v2 --"p:P2295"--> v9 v9 --"a"--> c11 v9 --"p:statement/P2295"--> v10 bind2[/"?revenue / ?profit"/] v5 --o bind2 v10 --o bind2 bind2 --as--o v11 bind3[/"numeric-round(?profmar * '1000^^xsd:integer') / '100^^xsd:integer'"/] v11 --o bind3 bind3 --as--o v11