query-105024786d87fde7bd9457e3ba8ca965
List of episodes of TV series. There is some trick to have data only from latter and avoid two row for the same episode? (Q3468580)Star Trek: Deep Space Nine, season 2 and at the same time is part of (Q7750266)The Maquis are reported 2 time because the episode is part of (Q42600893)The Maquis, Part II and 21 (Q42600888)The Maquis, Part I . In the result the episodes number 20 (Q21664088)two-part episode With this query I can extract all the episode of TV series or season, the problem is with
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT distinct ?serie ?serieLabel ?season ?seasonLabel ?seasonN2 ?episode ?episodeLabel ?episodeN ?seasonN ?prev ?next ?imdb ?date WHERE {
?episode wdt:P31 wd:Q21191270 .
?episode wdt:P179 wd:Q108774.
?episode wdt:P179 ?serie.
?episode wdt:P361 wd:Q3468580.
?episode wdt:P361 ?season.
OPTIONAL {?episode wdt:P1191 ?date .}
OPTIONAL {?episode wdt:P345 ?imdb .}
OPTIONAL {?episode wdt:P155 ?prev.}
OPTIONAL {?episode wdt:P156 ?next.}
?episode p:P179 ?statement .
?statement pq:P1545 ?episodeN .
?episode p:P361 ?statement2 .
OPTIONAL {?statement2 pq:P1545 ?seasonN .}
OPTIONAL {?season p:P179 ?statementSeason .}
OPTIONAL {?statementSeason pq:P1545 ?seasonN2 .}
OPTIONAL {?season wdt:P31 ?istance .}
FILTER (?istance = wd:Q3464665) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?serie xsd:integer(?seasonN2) xsd:integer(?episodeN)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?date"):::projected
v5("?episode"):::projected
v3("?episodeN"):::projected
v8("?imdb"):::projected
v4("?istance")
v10("?next"):::projected
v9("?prev"):::projected
v6("?season"):::projected
v13("?seasonN"):::projected
v2("?seasonN2"):::projected
v1("?serie"):::projected
v11("?statement")
v12("?statement2")
v14("?statementSeason")
c5(["wd:Q108774"]):::iri
c18(["en"]):::literal
c3(["wd:Q21191270"]):::iri
c16(["bd:serviceParam"]):::iri
c7(["wd:Q3468580"]):::iri
f0[["?istance = 'wd:Q3464665'"]]
f0 --> v4
v5 --"p:direct/P31"--> c3
v5 --"p:direct/P179"--> c5
v5 --"p:direct/P179"--> v1
v5 --"p:direct/P361"--> c7
v5 --"p:direct/P361"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P1191".-> v7
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P345".-> v8
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P155".-> v9
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v5 -."p:direct/P156".-> v10
end
v5 --"p:P179"--> v11
v11 --"p:qualifier/P1545"--> v3
v5 --"p:P361"--> v12
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v12 -."p:qualifier/P1545".-> v13
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:P179".-> v14
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v14 -."p:qualifier/P1545".-> v2
end
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v6 -."p:direct/P31".-> v4
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c16 --"wikibase:language"--> c18
end