User:Acebarry/queries
Queries I use edit
New Jersey Politics edit
NJ State Senate Map edit
#defaultView:Map
SELECT DISTINCT ?item ?itemLabel ?district ?districtLabel ?shape (SAMPLE(?image) AS ?image) ?group ?groupLabel (IF((MIN(?groupID)) = "0", "Republican", IF((MIN(?groupID)) = "1", "Democrat", "Other")) AS ?layer) WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item p:P39 ?rep.
?rep ps:P39 wd:Q19385767;
pq:P2937 wd:Q65087533;
pq:P768 ?district.
?district wdt:P3896 ?shape.
?rep pq:P4100 ?group.
BIND(IF(?group = wd:Q29468, "0", IF(?group = wd:Q29552, "1", "2")) AS ?groupID)
}
GROUP BY ?item ?itemLabel ?layer ?district ?districtLabel ?shape ?image ?group ?groupLabel
NJ Senate by Legislative Term edit
SELECT DISTINCT ?item ?itemLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item p:P39 ?stmt;
wdt:P31 wd:Q5.
?stmt ps:P39 wd:Q19385767;
pq:P2937 wd:Q110491007.
}
NJ Assembly by Legislative Term edit
SELECT DISTINCT ?item ?itemLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item p:P39 ?stmt;
wdt:P31 wd:Q5.
?stmt ps:P39 wd:Q18536527;
pq:P2937 wd:Q110491007.
}
New Jersey State Parks edit
ID QA edit
SELECT ?id ?idLabel ?fb ?gkg ?osm WHERE {
?id wdt:P31 wd:Q38000321.
OPTIONAL { ?id wdt:P646 ?fb. }
OPTIONAL { ?id wdt:P2671 ?gkg. }
OPTIONAL { ?id wdt:P402 ?osm. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY (?idLabel)
New Jersey Municipalities edit
ID QA edit
SELECT ?id ?idLabel ?fb ?gkg ?GNIS ?FIPS553 WHERE {
?id (wdt:P31/(wdt:P279*)) wd:Q54115138.
OPTIONAL { ?id wdt:P646 ?fb. }
OPTIONAL { ?id wdt:P2671 ?gkg. }
OPTIONAL { ?id wdt:P590 ?GNIS. }
OPTIONAL { ?id wdt:P774 ?FIPS553. }
FILTER(NOT EXISTS { ?id wdt:P576 ?eol. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY (?idLabel)
Population edit
Census edit
Select municipalities in NJ that *do not* have a population statement with point in time 1 April 2010. This is useful to find entries that don't have properly cited 2010 census data.
SELECT ?id ?idLabel WHERE {
?id (wdt:P31/(wdt:P279*)) wd:Q54115138;
#wdt:P131 wd:Q497928.
MINUS {
SELECT ?id WHERE {
?id (wdt:P31/(wdt:P279*)) wd:Q54115138;
p:P1082 ?popStatement;
#wdt:P131 wd:Q497928.
OPTIONAL {
?popStatement pq:P585 ?time;
pq:P459 ?det.
}
FILTER(?time = "2010-04-01"^^xsd:dateTime)
FILTER(NOT EXISTS { ?id wdt:P576 ?eol. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC (?population)
}
FILTER(NOT EXISTS { ?id wdt:P576 ?eol. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?id ?idLabel
No Population edit
Municipalities with no population listed. This should be empty.
SELECT ?id ?idLabel ?time ?detLabel WHERE {
?id (wdt:P31/(wdt:P279*)) wd:Q54115138.
FILTER(NOT EXISTS { ?id wdt:P1082 ?pop. })
FILTER(NOT EXISTS { ?id wdt:P576 ?eol. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY (?idLabel)
County Seats of New Jersey edit
SELECT ?id ?idLabel ?county ?countyLabel WHERE {
?id (wdt:P31/(wdt:P279*)) wd:Q54115138.
?id wdt:P31 wd:Q62049.
OPTIONAL { ?id wdt:P131 ?county. }
FILTER(NOT EXISTS { ?id wdt:P576 ?eol. })
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?countyLabel
Enclave Municipalities in New Jersey edit
SELECT (?border as ?id) WHERE {
{
SELECT ?border (COUNT(?ida) AS ?count) WHERE {
?ida (wdt:P31/(wdt:P279*)) wd:Q54115138;
wdt:P47 ?border.
?border (wdt:P31/(wdt:P279*)) wd:Q54115138.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
FILTER(NOT EXISTS { ?ida wdt:P576 ?dob. })
}
GROUP BY ?border
}
FILTER (?count = 1 ) .
}