query-be7d3b93c92d1a762d44a3fd92a80750
title: Get most recent Mastodon follower count
adapted from: https://stackoverflow.com/questions/36181713/sparql-query-to-get-only-results-with-the-most-recent-date
SELECT ?id ?address ?follower ?date WHERE { ?id p:P8687 ?statement . ?statement pq:P4033 ?address ; pq:P585 ?date ; ps:P8687 ?follower . FILTER NOT EXISTS { ?id p:P8687 [ pq:P585 ?date2 ] . FILTER (?date2 > ?date) } }
Use at
- https://query.wikidata.org/sparql
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
#title: Get most recent Mastodon follower count
# adapted from: https://stackoverflow.com/questions/36181713/sparql-query-to-get-only-results-with-the-most-recent-date
SELECT ?id ?address ?follower ?date WHERE {
?id p:P8687 ?statement .
?statement pq:P4033 ?address ;
pq:P585 ?date ;
ps:P8687 ?follower .
FILTER NOT EXISTS {
?id p:P8687 [ pq:P585 ?date2 ] .
FILTER (?date2 > ?date)
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?address"):::projected
v2("?date"):::projected
v1("?date2")
v6("?follower"):::projected
v3("?id"):::projected
v4("?statement")
a1((" "))
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0f0[["?date2 > ?date"]]
e0f0 --> e0v1
e0f0 --> e0v2
e0a1 --"p:qualifier/P585"--> e0v1
e0v3 --"p:P8687"--> e0a1
e0v2("?date"):::projected
e0v1("?date2"):::projected
e0v3("?id"):::projected
e0a1((" ")):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> v2
f0 --> a1
f0 --> c1
f0 --> v3
f0 --> c2
f1[["?date2 > ?date"]]
f1 --> v1
f1 --> v2
a1 --"p:qualifier/P585"--> v1
v3 --"p:P8687"--> a1
v3 --"p:P8687"--> v4
v4 --"p:qualifier/P4033"--> v5
v4 --"p:qualifier/P585"--> v2
v4 --"p:statement/P8687"--> v6