query-54b1d2359a2d16a43deb584cdf5b68e1
rq turtle/ttl
Demo using Infectious Disease specialty.
(1) Conditions usually imposed on the publisher are just assumed.
(2) The line "?mainsubject wdt:P1995 wd:Q788926" would causes a bound variable clash,
with the OPTIONAL section, so the variable ?mainsubject1 is used instead.
(3) The filter line, comparing ?medrsyear ?ynow, is omitted.
(4) The results are in chronological order.
SELECT DISTINCT ?article ?articleLabel ?journal ?journalLabel ?bound ?medrsyear ?ynow
WHERE {
?journal wdt:P31 wd:Q5633421;
wdt:P123 ?publisher.
?article wdt:P5008 wd:Q55439927;
wdt:P31 wd:Q7318358;
wdt:P1433 ?journal;
wdt:P577 ?date;
wdt:P921 ?mainsubject1.
?mainsubject1 wdt:P1995 wd:Q788926.
{?journal wdt:P31 wd:Q5953270}
UNION {VALUES ?journal {wd:Q546003 wd:Q2928049 wd:Q5030320 wd:Q5690746 wd:Q6047666
wd:Q26841926 wd:Q1763668 wd:Q2025726 wd:Q15724513 wd:Q2456339
wd:Q27722384 wd:Q27667673}
}
UNION {?journal wdt:P5115 [ ].}
MINUS {
{?article wdt:P31 wd:Q45182324}
UNION
{?article wdt:P5824 [ ]}
UNION
{VALUES ?publisher {wd:Q52636754 wd:Q52635805 wd:Q4689899 wd:Q52620137 wd:Q4732612
wd:Q43080819 wd:Q30270870 wd:Q30297686 wd:Q52661346 wd:Q52636079
wd:Q52557383 wd:Q54958933 wd:Q2896740 wd:Q63254475 wd:Q18712923
wd:Q52609680 wd:Q52609536 wd:Q52636154 wd:Q52609215 wd:Q80796
wd:Q52636535 wd:Q52633727 wd:Q52636944 wd:Q63254434 wd:Q52637577
wd:Q52665969 wd:Q52660711 wd:Q52659576 wd:Q56979398 wd:Q52670242
wd:Q29891111 wd:Q52619294 wd:Q52662151 wd:Q7072722 wd:Q52609375
wd:Q7259709 wd:Q52636843 wd:Q45251004 wd:Q52637573 wd:Q52662489
wd:Q52635330 wd:Q47116994 wd:Q30267116 wd:Q24706265 wd:Q52620720
wd:Q52633876 wd:Q56416796 wd:Q52660351 wd:Q52635690 wd:Q7433770
wd:Q27991304 wd:Q55566796 wd:Q52619286 wd:Q30265175 wd:Q8035326}
}
UNION
{VALUES ?article {wd:Q26746153}
}
}
OPTIONAL {VALUES ?mainsubject {wd:Q949694 wd:Q2447562 wd:Q649558 wd:Q326071 wd:Q203133
wd:Q842428 wd:Q11679861 wd:Q2264130 wd:Q2360849 wd:Q1345113
wd:Q1597571 wd:Q2841329 wd:Q2665559 wd:Q30953 wd:Q738292
wd:Q154874 wd:Q2859732 wd:Q39222 wd:Q326638 wd:Q162272
wd:Q809561 wd:Q18975737 wd:Q1017169 wd:Q12090 wd:Q327298
wd:Q326648 wd:Q18975220 wd:Q36956 wd:Q155098 wd:Q690032
wd:Q193216 wd:Q682798 wd:Q922029 wd:Q41083 wd:Q76973
wd:Q16877704 wd:Q247096 wd:Q167178 wd:Q304601 wd:Q331283
wd:Q1475667 wd:Q388646 wd:Q777087 wd:Q1102300 wd:Q1048084
wd:Q719656 wd:Q2528129 wd:Q1760607 wd:Q192100 wd:Q1137321
wd:Q221159 }
?article wdt:P921 ?mainsubject.}
BIND(xsd:boolean(COALESCE(BOUND(?mainsubject),"false")) AS ?bound)
BIND(year(?date) AS ?ydate)
BIND(year(now()) AS ?ynow)
BIND((IF(?bound,?ydate+8,?ydate+5)) AS ?medrsyear)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY ASC(?date)
LIMIT 1000
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 bd: <http://www.bigdata.com/rdf#>
#Demo using Infectious Disease specialty.
#(1) Conditions usually imposed on the publisher are just assumed.
#(2) The line "?mainsubject wdt:P1995 wd:Q788926" would causes a bound variable clash,
#with the OPTIONAL section, so the variable ?mainsubject1 is used instead.
#(3) The filter line, comparing ?medrsyear ?ynow, is omitted.
#(4) The results are in chronological order.
SELECT DISTINCT ?article ?articleLabel ?journal ?journalLabel ?bound ?medrsyear ?ynow
WHERE {
?journal wdt:P31 wd:Q5633421;
wdt:P123 ?publisher.
?article wdt:P5008 wd:Q55439927;
wdt:P31 wd:Q7318358;
wdt:P1433 ?journal;
wdt:P577 ?date;
wdt:P921 ?mainsubject1.
?mainsubject1 wdt:P1995 wd:Q788926.
{?journal wdt:P31 wd:Q5953270}
UNION {VALUES ?journal {wd:Q546003 wd:Q2928049 wd:Q5030320 wd:Q5690746 wd:Q6047666
wd:Q26841926 wd:Q1763668 wd:Q2025726 wd:Q15724513 wd:Q2456339
wd:Q27722384 wd:Q27667673}
}
UNION {?journal wdt:P5115 [ ].}
MINUS {
{?article wdt:P31 wd:Q45182324}
UNION
{?article wdt:P5824 [ ]}
UNION
{VALUES ?publisher {wd:Q52636754 wd:Q52635805 wd:Q4689899 wd:Q52620137 wd:Q4732612
wd:Q43080819 wd:Q30270870 wd:Q30297686 wd:Q52661346 wd:Q52636079
wd:Q52557383 wd:Q54958933 wd:Q2896740 wd:Q63254475 wd:Q18712923
wd:Q52609680 wd:Q52609536 wd:Q52636154 wd:Q52609215 wd:Q80796
wd:Q52636535 wd:Q52633727 wd:Q52636944 wd:Q63254434 wd:Q52637577
wd:Q52665969 wd:Q52660711 wd:Q52659576 wd:Q56979398 wd:Q52670242
wd:Q29891111 wd:Q52619294 wd:Q52662151 wd:Q7072722 wd:Q52609375
wd:Q7259709 wd:Q52636843 wd:Q45251004 wd:Q52637573 wd:Q52662489
wd:Q52635330 wd:Q47116994 wd:Q30267116 wd:Q24706265 wd:Q52620720
wd:Q52633876 wd:Q56416796 wd:Q52660351 wd:Q52635690 wd:Q7433770
wd:Q27991304 wd:Q55566796 wd:Q52619286 wd:Q30265175 wd:Q8035326}
}
UNION
{VALUES ?article {wd:Q26746153}
}
}
OPTIONAL {VALUES ?mainsubject {wd:Q949694 wd:Q2447562 wd:Q649558 wd:Q326071 wd:Q203133
wd:Q842428 wd:Q11679861 wd:Q2264130 wd:Q2360849 wd:Q1345113
wd:Q1597571 wd:Q2841329 wd:Q2665559 wd:Q30953 wd:Q738292
wd:Q154874 wd:Q2859732 wd:Q39222 wd:Q326638 wd:Q162272
wd:Q809561 wd:Q18975737 wd:Q1017169 wd:Q12090 wd:Q327298
wd:Q326648 wd:Q18975220 wd:Q36956 wd:Q155098 wd:Q690032
wd:Q193216 wd:Q682798 wd:Q922029 wd:Q41083 wd:Q76973
wd:Q16877704 wd:Q247096 wd:Q167178 wd:Q304601 wd:Q331283
wd:Q1475667 wd:Q388646 wd:Q777087 wd:Q1102300 wd:Q1048084
wd:Q719656 wd:Q2528129 wd:Q1760607 wd:Q192100 wd:Q1137321
wd:Q221159 }
?article wdt:P921 ?mainsubject.}
BIND(xsd:boolean(COALESCE(BOUND(?mainsubject),"false")) AS ?bound)
BIND(year(?date) AS ?ydate)
BIND(year(now()) AS ?ynow)
BIND((IF(?bound,?ydate+8,?ydate+5)) AS ?medrsyear)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
ORDER BY ASC(?date)
LIMIT 1000
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?article"):::projected
v7("?bound"):::projected
v1("?date")
v6("?journal"):::projected
v6("?mainsubject")
v5("?mainsubject1")
v10("?medrsyear"):::projected
v6("?publisher")
v8("?ydate")
v9("?ynow"):::projected
a1((" "))
a2((" "))
c5(["wd:Q55439927"]):::iri
c6(["wd:Q7318358"]):::iri
c2(["wd:Q5633421"]):::iri
c11(["wd:Q788926"]):::iri
c17(["bd:serviceParam"]):::iri
c12(["wd:Q5953270"]):::iri
c14(["wd:Q45182324"]):::iri
c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v6 --"wdt:P31"--> c2
v6 --"wdt:P123"--> v6
v6 --"wdt:P5008"--> c5
v6 --"wdt:P31"--> c6
v6 --"wdt:P1433"--> v6
v6 --"wdt:P577"--> v1
v6 --"wdt:P921"--> v5
v5 --"wdt:P1995"--> c11
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P5115"--> a1
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
bind0[/VALUES ?journal/]
bind0-->v6
bind00(["wd:Q546003"])
bind00 --> bind0
bind01(["wd:Q2928049"])
bind01 --> bind0
bind02(["wd:Q5030320"])
bind02 --> bind0
bind03(["wd:Q5690746"])
bind03 --> bind0
bind04(["wd:Q6047666"])
bind04 --> bind0
bind05(["wd:Q26841926"])
bind05 --> bind0
bind06(["wd:Q1763668"])
bind06 --> bind0
bind07(["wd:Q2025726"])
bind07 --> bind0
bind08(["wd:Q15724513"])
bind08 --> bind0
bind09(["wd:Q2456339"])
bind09 --> bind0
bind010(["wd:Q27722384"])
bind010 --> bind0
bind011(["wd:Q27667673"])
bind011 --> bind0
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P31"--> c12
end
union0r <== or ==> union0l
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph union3[" Union "]
subgraph union3l[" "]
style union3l fill:#abf,stroke-dasharray: 3 3;
subgraph union4[" Union "]
subgraph union4l[" "]
style union4l fill:#abf,stroke-dasharray: 3 3;
bind2[/VALUES ?article/]
bind2-->v6
bind20(["wd:Q26746153"])
bind20 --> bind2
end
subgraph union4r[" "]
style union4r fill:#abf,stroke-dasharray: 3 3;
bind3[/VALUES ?publisher/]
bind3-->v6
bind30(["wd:Q52636754"])
bind30 --> bind3
bind31(["wd:Q52635805"])
bind31 --> bind3
bind32(["wd:Q4689899"])
bind32 --> bind3
bind33(["wd:Q52620137"])
bind33 --> bind3
bind34(["wd:Q4732612"])
bind34 --> bind3
bind35(["wd:Q43080819"])
bind35 --> bind3
bind36(["wd:Q30270870"])
bind36 --> bind3
bind37(["wd:Q30297686"])
bind37 --> bind3
bind38(["wd:Q52661346"])
bind38 --> bind3
bind39(["wd:Q52636079"])
bind39 --> bind3
bind310(["wd:Q52557383"])
bind310 --> bind3
bind311(["wd:Q54958933"])
bind311 --> bind3
bind312(["wd:Q2896740"])
bind312 --> bind3
bind313(["wd:Q63254475"])
bind313 --> bind3
bind314(["wd:Q18712923"])
bind314 --> bind3
bind315(["wd:Q52609680"])
bind315 --> bind3
bind316(["wd:Q52609536"])
bind316 --> bind3
bind317(["wd:Q52636154"])
bind317 --> bind3
bind318(["wd:Q52609215"])
bind318 --> bind3
bind319(["wd:Q80796"])
bind319 --> bind3
bind320(["wd:Q52636535"])
bind320 --> bind3
bind321(["wd:Q52633727"])
bind321 --> bind3
bind322(["wd:Q52636944"])
bind322 --> bind3
bind323(["wd:Q63254434"])
bind323 --> bind3
bind324(["wd:Q52637577"])
bind324 --> bind3
bind325(["wd:Q52665969"])
bind325 --> bind3
bind326(["wd:Q52660711"])
bind326 --> bind3
bind327(["wd:Q52659576"])
bind327 --> bind3
bind328(["wd:Q56979398"])
bind328 --> bind3
bind329(["wd:Q52670242"])
bind329 --> bind3
bind330(["wd:Q29891111"])
bind330 --> bind3
bind331(["wd:Q52619294"])
bind331 --> bind3
bind332(["wd:Q52662151"])
bind332 --> bind3
bind333(["wd:Q7072722"])
bind333 --> bind3
bind334(["wd:Q52609375"])
bind334 --> bind3
bind335(["wd:Q7259709"])
bind335 --> bind3
bind336(["wd:Q52636843"])
bind336 --> bind3
bind337(["wd:Q45251004"])
bind337 --> bind3
bind338(["wd:Q52637573"])
bind338 --> bind3
bind339(["wd:Q52662489"])
bind339 --> bind3
bind340(["wd:Q52635330"])
bind340 --> bind3
bind341(["wd:Q47116994"])
bind341 --> bind3
bind342(["wd:Q30267116"])
bind342 --> bind3
bind343(["wd:Q24706265"])
bind343 --> bind3
bind344(["wd:Q52620720"])
bind344 --> bind3
bind345(["wd:Q52633876"])
bind345 --> bind3
bind346(["wd:Q56416796"])
bind346 --> bind3
bind347(["wd:Q52660351"])
bind347 --> bind3
bind348(["wd:Q52635690"])
bind348 --> bind3
bind349(["wd:Q7433770"])
bind349 --> bind3
bind350(["wd:Q27991304"])
bind350 --> bind3
bind351(["wd:Q55566796"])
bind351 --> bind3
bind352(["wd:Q52619286"])
bind352 --> bind3
bind353(["wd:Q30265175"])
bind353 --> bind3
bind354(["wd:Q8035326"])
bind354 --> bind3
end
union4r <== or ==> union4l
end
end
subgraph union3r[" "]
style union3r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P5824"--> a2
end
union3r <== or ==> union3l
end
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P31"--> c14
end
union2r <== or ==> union2l
end
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
bind4[/VALUES ?mainsubject/]
bind4-->v6
bind40(["wd:Q949694"])
bind40 --> bind4
bind41(["wd:Q2447562"])
bind41 --> bind4
bind42(["wd:Q649558"])
bind42 --> bind4
bind43(["wd:Q326071"])
bind43 --> bind4
bind44(["wd:Q203133"])
bind44 --> bind4
bind45(["wd:Q842428"])
bind45 --> bind4
bind46(["wd:Q11679861"])
bind46 --> bind4
bind47(["wd:Q2264130"])
bind47 --> bind4
bind48(["wd:Q2360849"])
bind48 --> bind4
bind49(["wd:Q1345113"])
bind49 --> bind4
bind410(["wd:Q1597571"])
bind410 --> bind4
bind411(["wd:Q2841329"])
bind411 --> bind4
bind412(["wd:Q2665559"])
bind412 --> bind4
bind413(["wd:Q30953"])
bind413 --> bind4
bind414(["wd:Q738292"])
bind414 --> bind4
bind415(["wd:Q154874"])
bind415 --> bind4
bind416(["wd:Q2859732"])
bind416 --> bind4
bind417(["wd:Q39222"])
bind417 --> bind4
bind418(["wd:Q326638"])
bind418 --> bind4
bind419(["wd:Q162272"])
bind419 --> bind4
bind420(["wd:Q809561"])
bind420 --> bind4
bind421(["wd:Q18975737"])
bind421 --> bind4
bind422(["wd:Q1017169"])
bind422 --> bind4
bind423(["wd:Q12090"])
bind423 --> bind4
bind424(["wd:Q327298"])
bind424 --> bind4
bind425(["wd:Q326648"])
bind425 --> bind4
bind426(["wd:Q18975220"])
bind426 --> bind4
bind427(["wd:Q36956"])
bind427 --> bind4
bind428(["wd:Q155098"])
bind428 --> bind4
bind429(["wd:Q690032"])
bind429 --> bind4
bind430(["wd:Q193216"])
bind430 --> bind4
bind431(["wd:Q682798"])
bind431 --> bind4
bind432(["wd:Q922029"])
bind432 --> bind4
bind433(["wd:Q41083"])
bind433 --> bind4
bind434(["wd:Q76973"])
bind434 --> bind4
bind435(["wd:Q16877704"])
bind435 --> bind4
bind436(["wd:Q247096"])
bind436 --> bind4
bind437(["wd:Q167178"])
bind437 --> bind4
bind438(["wd:Q304601"])
bind438 --> bind4
bind439(["wd:Q331283"])
bind439 --> bind4
bind440(["wd:Q1475667"])
bind440 --> bind4
bind441(["wd:Q388646"])
bind441 --> bind4
bind442(["wd:Q777087"])
bind442 --> bind4
bind443(["wd:Q1102300"])
bind443 --> bind4
bind444(["wd:Q1048084"])
bind444 --> bind4
bind445(["wd:Q719656"])
bind445 --> bind4
bind446(["wd:Q2528129"])
bind446 --> bind4
bind447(["wd:Q1760607"])
bind447 --> bind4
bind448(["wd:Q192100"])
bind448 --> bind4
bind449(["wd:Q1137321"])
bind449 --> bind4
bind450(["wd:Q221159"])
bind450 --> bind4
v6 -."wdt:P921".-> v6
end
bind5[/"http://www.w3.org/2001/XMLSchema#boolean(bound(?mainsubject)'false')"/]
v6 --o bind5
bind5 --as--o v7
bind6[/"year-from-dateTime(?date)"/]
v1 --o bind6
bind6 --as--o v8
bind7[/"year-from-dateTime(NOW())"/]
bind7 --as--o v9
bind8[/"if(?bound,?ydate + '+8^^xsd:integer',?ydate + '+5^^xsd:integer')"/]
v7 --o bind8
v8 --o bind8
bind8 --as--o v10
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c17 --"wikibase:language"--> c19
end