sparql-examples

A set of SPARQL examples that are used in different AMC resources

View the Project on GitHub AmsterdamUMC/sparql-examples

003

Maandelijkse aantallen met procentuele verdeling per item

Use at


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX gido: <http://www.semanticweb.org/gido#>
PREFIX ex: <http://example.org/ex#>

SELECT ?s ?omschrijving
       ?jan (CONCAT(STR(ROUND((?jan * 100.0 / ?total) * 100) / 100), "%") AS ?jan_pct)
       ?feb (CONCAT(STR(ROUND((?feb * 100.0 / ?total) * 100) / 100), "%") AS ?feb_pct)
       ?mar (CONCAT(STR(ROUND((?mar * 100.0 / ?total) * 100) / 100), "%") AS ?mar_pct)
       ?apr (CONCAT(STR(ROUND((?apr * 100.0 / ?total) * 100) / 100), "%") AS ?apr_pct)
       ?may (CONCAT(STR(ROUND((?may * 100.0 / ?total) * 100) / 100), "%") AS ?may_pct)
       ?jun (CONCAT(STR(ROUND((?jun * 100.0 / ?total) * 100) / 100), "%") AS ?jun_pct)
       ?jul (CONCAT(STR(ROUND((?jul * 100.0 / ?total) * 100) / 100), "%") AS ?jul_pct)
       ?aug (CONCAT(STR(ROUND((?aug * 100.0 / ?total) * 100) / 100), "%") AS ?aug_pct)
       ?sep (CONCAT(STR(ROUND((?sep * 100.0 / ?total) * 100) / 100), "%") AS ?sep_pct)
       ?oct (CONCAT(STR(ROUND((?oct * 100.0 / ?total) * 100) / 100), "%") AS ?oct_pct)
       ?nov (CONCAT(STR(ROUND((?nov * 100.0 / ?total) * 100) / 100), "%") AS ?nov_pct)
       ?dec (CONCAT(STR(ROUND((?dec * 100.0 / ?total) * 100) / 100), "%") AS ?dec_pct)
WHERE {
    {
        SELECT ?s ?omschrijving ?jan ?feb ?mar ?apr ?may ?jun ?jul ?aug ?sep ?oct ?nov ?dec
               (SUM(?jan + ?feb + ?mar + ?apr + ?may + ?jun + ?jul + ?aug + ?sep + ?oct + ?nov + ?dec) AS ?total)
        WHERE {
            ?s rdf:type gido:Glove ;
               ex:Omschrijving_artikel_intern ?omschrijving ;
               ex:jan ?jan ;
               ex:feb ?feb ;
               ex:mar ?mar ;
               ex:apr ?apr ;
               ex:may ?may ;
               ex:jun ?jun ;
               ex:jul ?jul ;
               ex:aug ?aug ;
               ex:sep ?sep ;
               ex:oct ?oct ;
               ex:nov ?nov ;
               ex:dec ?dec .
        }
        GROUP BY ?s ?omschrijving ?jan ?feb ?mar ?apr ?may ?jun ?jul ?aug ?sep ?oct ?nov ?dec
    }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v6("?apr"):::projected 
  v19("?apr_pct")
  v10("?aug"):::projected 
  v23("?aug_pct")
  v14("?dec"):::projected 
  v27("?dec_pct")
  v4("?feb"):::projected 
  v17("?feb_pct")
  v3("?jan"):::projected 
  v16("?jan_pct")
  v9("?jul"):::projected 
  v22("?jul_pct")
  v8("?jun"):::projected 
  v21("?jun_pct")
  v5("?mar"):::projected 
  v18("?mar_pct")
  v7("?may"):::projected 
  v20("?may_pct")
  v13("?nov"):::projected 
  v26("?nov_pct")
  v12("?oct"):::projected 
  v25("?oct_pct")
  v2("?omschrijving"):::projected 
  v1("?s"):::projected 
  v11("?sep"):::projected 
  v24("?sep_pct")
  v15("?total"):::projected 
  c2([http://www.semanticweb.org/gido#Glove]):::iri 
  v1 --"a"-->  c2
  v1 --http://example.org/ex#Omschrijving_artikel_intern-->  v2
  v1 --http://example.org/ex#jan-->  v3
  v1 --http://example.org/ex#feb-->  v4
  v1 --http://example.org/ex#mar-->  v5
  v1 --http://example.org/ex#apr-->  v6
  v1 --http://example.org/ex#may-->  v7
  v1 --http://example.org/ex#jun-->  v8
  v1 --http://example.org/ex#jul-->  v9
  v1 --http://example.org/ex#aug-->  v10
  v1 --http://example.org/ex#sep-->  v11
  v1 --http://example.org/ex#oct-->  v12
  v1 --http://example.org/ex#nov-->  v13
  v1 --http://example.org/ex#dec-->  v14
  bind1[/"sum(?jan + ?feb + ?mar + ?apr + ?may + ?jun + ?jul + ?aug + ?sep + ?oct + ?nov + ?dec)"/]
  v3 --o bind1
  v4 --o bind1
  v5 --o bind1
  v6 --o bind1
  v7 --o bind1
  v8 --o bind1
  v9 --o bind1
  v10 --o bind1
  v11 --o bind1
  v12 --o bind1
  v13 --o bind1
  v14 --o bind1
  bind1 --as--o v15
  bind2[/"concat(str(numeric-round(?jan * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v3 --o bind2
  v15 --o bind2
  bind2 --as--o v16
  bind3[/"concat(str(numeric-round(?feb * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v4 --o bind3
  v15 --o bind3
  bind3 --as--o v17
  bind4[/"concat(str(numeric-round(?mar * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v5 --o bind4
  v15 --o bind4
  bind4 --as--o v18
  bind5[/"concat(str(numeric-round(?apr * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v6 --o bind5
  v15 --o bind5
  bind5 --as--o v19
  bind6[/"concat(str(numeric-round(?may * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v7 --o bind6
  v15 --o bind6
  bind6 --as--o v20
  bind7[/"concat(str(numeric-round(?jun * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v8 --o bind7
  v15 --o bind7
  bind7 --as--o v21
  bind8[/"concat(str(numeric-round(?jul * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v9 --o bind8
  v15 --o bind8
  bind8 --as--o v22
  bind9[/"concat(str(numeric-round(?aug * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v10 --o bind9
  v15 --o bind9
  bind9 --as--o v23
  bind10[/"concat(str(numeric-round(?sep * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v11 --o bind10
  v15 --o bind10
  bind10 --as--o v24
  bind11[/"concat(str(numeric-round(?oct * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v12 --o bind11
  v15 --o bind11
  bind11 --as--o v25
  bind12[/"concat(str(numeric-round(?nov * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v13 --o bind12
  v15 --o bind12
  bind12 --as--o v26
  bind13[/"concat(str(numeric-round(?dec * '100.0^^xsd:decimal' / ?total * '100^^xsd:integer') / '100^^xsd:integer'),'%')"/]
  v14 --o bind13
  v15 --o bind13
  bind13 --as--o v27