Project:SPARQL/examples

From Waste Commons Scotland
Jump to navigation Jump to search

Examples

The council areas of Scotland with their UK government codes

PREFIX wd: <http://waste-commons-scotland.wiki.opencura.com/entity/>
PREFIX wdt: <http://waste-commons-scotland.wiki.opencura.com/prop/direct/>
SELECT
  ?areaLabel
  ?ukGovCode
WHERE {  
  ?area wdt:P7 wd:Q1;
        wdt:P8 wd:Q2;
        wdt:P10 ?ukGovCode.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } 
}
ORDER BY ?areaLabel

Try it!


The tonnes of household waste (solids) per citizen per area per year

PREFIX wd: <http://waste-commons-scotland.wiki.opencura.com/entity/>
PREFIX wdt: <http://waste-commons-scotland.wiki.opencura.com/prop/direct/>
SELECT
  ?areaLabel
  (YEAR(?time) AS ?year)
  ?endStateLabel 
  (?wasteQuantity/?populationQuantity AS ?quantity)
WHERE {  
  ?waste wdt:P7 wd:Q663;
         wdt:P5 ?wasteQuantity;
         wdt:P11 ?endState;
         wdt:P9 ?area;
         wdt:P6 ?time.
  ?population wdt:P7 wd:Q35;
              wdt:P5 ?populationQuantity;
              wdt:P9 ?area;
              wdt:P6 ?time.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } 
}
ORDER BY ?areaLabel ?year ?endState

Try it!


The tonnes of CO2e (from household waste) per citizen per area per year

PREFIX wd: <http://waste-commons-scotland.wiki.opencura.com/entity/>
PREFIX wdt: <http://waste-commons-scotland.wiki.opencura.com/prop/direct/>
SELECT
  ?areaLabel
  (YEAR(?time) AS ?year)
  (?co2eQuantity/?populationQuantity AS ?quantity)
WHERE {  
  ?co2e wdt:P7 wd:Q1461;
        wdt:P5 ?co2eQuantity;
        wdt:P9 ?area;
        wdt:P6 ?time.
  ?population wdt:P7 wd:Q35;
              wdt:P5 ?populationQuantity;
              wdt:P9 ?area;
              wdt:P6 ?time.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } 
}
ORDER BY ?areaLabel ?year

Try it!