query-7184f09700e54108b702841be8e1024c
RboatrightTagishsimon
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?light_years_from_earth ?parallax
WHERE
{
{
SELECT ?item (SAMPLE(?dist_to_earth * 0.000000000000000105700083402461546370946) AS ?light_years_from_earth)
(SAMPLE(?parallax_) AS ?parallax)
WHERE
{
{
# Get items between 1 and 30 lights years away
?P2583_statement psn:P2583 ?nvalue .
?nvalue wikibase:quantityAmount ?dist_to_earth .
FILTER (?dist_to_earth > 9460730472580800.0 && ?dist_to_earth <= 283821914177424000.0) # Distance is 1 to 30 light years
?P2583_statement a wikibase:BestRank. # Do only use best rank values
?item p:P2583 ?P2583_statement .
OPTIONAL { ?item wdt:P2214 ?parallax_ . }
}
UNION
{
# Get items with a parallax greater than 100 milli arch seconds
?item wdt:P2214 ?parallax_.
# The paralax unit is always milli arch second (See [[Wikidata:Database reports/Constraint violations/P2214#Units statistics]])
FILTER (?parallax_ > 100.0)
OPTIONAL { ?item p:P2583/psn:P2583/wikibase:quantityAmount ?dist_to_earth . }
}
?item wdt:P31/wdt:P279* wd:Q523 . # Check that ?item is a star (remember to include subclasses of star!)
}
GROUP BY ?item
} SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?P2583_statement")
v1("?dist_to_earth")
v4("?item"):::projected
v6("?light_years_from_earth"):::projected
v3("?nvalue")
v7("?parallax"):::projected
v5("?parallax_")
a1((" "))
a2((" "))
a3((" "))
c6(["wikibase:BestRank"]):::iri
c12(["wd:Q523"]):::iri
c15(["bd:serviceParam"]):::iri
c17(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f0[["?parallax_ > '100.0^^xsd:decimal'"]]
f0 --> v5
v4 --"p:direct/P2214"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:P2583".-> a1
a1 --"p:statement/value-normalized/P2583"--> a2
a2 --"wikibase:quantityAmount"--> v1
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f1[["?dist_to_earth > '9460730472580800.0^^xsd:decimal'?dist_to_earth <= '283821914177424000.0^^xsd:decimal'"]]
f1 --> v1
v2 --"p:statement/value-normalized/P2583"--> v3
v3 --"wikibase:quantityAmount"--> v1
v2 --"a"--> c6
v4 --"p:P2583"--> v2
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P2214".-> v5
end
end
union0r <== or ==> union0l
end
v4 --"p:direct/P31"--> a3
a3 --"p:direct/P279"--> c12
bind4[/"sample(?dist_to_earth * '0.000000000000000105700083402461546370946^^xsd:decimal')"/]
v1 --o bind4
bind4 --as--o v6
bind5[/"sample(?parallax_)"/]
v5 --o bind5
bind5 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end