query-197f9460aeda3b6b30548479cf5afb6d

rq turtle/ttl

Find by P921 'main subject'

Use at

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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?itemLabel ?publishedIn ?year ?month ?month_int ?day  ?authorLabel ?author2Label ?authors WHERE
{
   { 
  SELECT ?item ?itemLabel ?publishedIn ?year ?month ?month_int ?day ?authorLabel ?author2Label WHERE 
  {
    ?item wdt:P921 wd:Q30 .
    ?item wdt:P31 wd:Q13442814 .
    filter not exists {?item schema:description ?desc_en . filter(lang(?desc_en)="en")}                 

    OPTIONAL {?item p:P50 ?stat . 
      ?stat ps:P50 ?author. 
      ?stat pq:P1545 "1"^^xsd:string . 
      ?author rdfs:label ?authorLabel . filter(lang(?authorLabel)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat2 . 
      ?stat2 ps:P2093 ?authorLabel. 
      ?stat2 pq:P1545 "1"^^xsd:string .
    }

    OPTIONAL {?item p:P50 ?stat3 . 
      ?stat3 ps:P50 ?author2. 
      ?stat3 pq:P1545 "2"^^xsd:string . 
      ?author2 rdfs:label ?author2Label . filter(lang(?author2Label)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat4 . 
      ?stat4 ps:P2093 ?author2Label. 
      ?stat4 pq:P1545 "2"^^xsd:string .
    }

    OPTIONAL {?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en") }
    OPTIONAL {?item wdt:P1433/rdfs:label ?publishedIn . filter(lang(?publishedIn)="en") }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node .
             ?pub_date_node wikibase:timePrecision "9"^^xsd:integer .
             ?pub_date_node wikibase:timeValue ?date9 . 
             BIND(YEAR(?date9) as ?year) }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node2 .
             ?pub_date_node2 wikibase:timePrecision "10"^^xsd:integer .
             ?pub_date_node2 wikibase:timeValue ?date10 . 
             BIND(YEAR(?date10) as ?year) 
             BIND(MONTH(?date10) as ?month_int_) 
             ?month_ p:P279 ?month_stat . 
             ?month_stat ps:P279 wd:Q18602249.
             BIND(xsd:string(?month_int_) as ?month_int)
             ?month_stat pq:P1545 ?month_int .
             ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node3 .
              ?pub_date_node3 wikibase:timePrecision "11"^^xsd:integer .
              ?pub_date_node3 wikibase:timeValue ?date11 . 
              BIND(YEAR(?date11) as ?year) 
              BIND(MONTH(?date11) as ?month_int_) 
              BIND(DAY(?date11) as ?day)
              ?month_ p:P279 ?month_stat . 
              ?month_stat ps:P279 wd:Q18602249.
              BIND(xsd:string(?month_int_) as ?month_int)
              ?month_stat pq:P1545 ?month_int .
              ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }
  } 
}   { 
  SELECT ?item (COUNT(?authorP50) as ?countP50) WHERE 
  {
     { 
  SELECT ?item ?itemLabel ?publishedIn ?year ?month ?month_int ?day ?authorLabel ?author2Label WHERE 
  {
    ?item wdt:P921 wd:Q30 .
    ?item wdt:P31 wd:Q13442814 .
    filter not exists {?item schema:description ?desc_en . filter(lang(?desc_en)="en")}                 

    OPTIONAL {?item p:P50 ?stat . 
      ?stat ps:P50 ?author. 
      ?stat pq:P1545 "1"^^xsd:string . 
      ?author rdfs:label ?authorLabel . filter(lang(?authorLabel)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat2 . 
      ?stat2 ps:P2093 ?authorLabel. 
      ?stat2 pq:P1545 "1"^^xsd:string .
    }

    OPTIONAL {?item p:P50 ?stat3 . 
      ?stat3 ps:P50 ?author2. 
      ?stat3 pq:P1545 "2"^^xsd:string . 
      ?author2 rdfs:label ?author2Label . filter(lang(?author2Label)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat4 . 
      ?stat4 ps:P2093 ?author2Label. 
      ?stat4 pq:P1545 "2"^^xsd:string .
    }

    OPTIONAL {?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en") }
    OPTIONAL {?item wdt:P1433/rdfs:label ?publishedIn . filter(lang(?publishedIn)="en") }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node .
             ?pub_date_node wikibase:timePrecision "9"^^xsd:integer .
             ?pub_date_node wikibase:timeValue ?date9 . 
             BIND(YEAR(?date9) as ?year) }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node2 .
             ?pub_date_node2 wikibase:timePrecision "10"^^xsd:integer .
             ?pub_date_node2 wikibase:timeValue ?date10 . 
             BIND(YEAR(?date10) as ?year) 
             BIND(MONTH(?date10) as ?month_int_) 
             ?month_ p:P279 ?month_stat . 
             ?month_stat ps:P279 wd:Q18602249.
             BIND(xsd:string(?month_int_) as ?month_int)
             ?month_stat pq:P1545 ?month_int .
             ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node3 .
              ?pub_date_node3 wikibase:timePrecision "11"^^xsd:integer .
              ?pub_date_node3 wikibase:timeValue ?date11 . 
              BIND(YEAR(?date11) as ?year) 
              BIND(MONTH(?date11) as ?month_int_) 
              BIND(DAY(?date11) as ?day)
              ?month_ p:P279 ?month_stat . 
              ?month_stat ps:P279 wd:Q18602249.
              BIND(xsd:string(?month_int_) as ?month_int)
              ?month_stat pq:P1545 ?month_int .
              ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }
  } 
}       
    OPTIONAL {?item wdt:P50 ?authorP50 . }
  } group by ?item 
}   { 
  SELECT ?item (COUNT(?authorP2093) as ?countP2093) WHERE 
  {
     { 
  SELECT ?item ?itemLabel ?publishedIn ?year ?month ?month_int ?day ?authorLabel ?author2Label WHERE 
  {
    ?item wdt:P921 wd:Q30 .
    ?item wdt:P31 wd:Q13442814 .
    filter not exists {?item schema:description ?desc_en . filter(lang(?desc_en)="en")}                 

    OPTIONAL {?item p:P50 ?stat . 
      ?stat ps:P50 ?author. 
      ?stat pq:P1545 "1"^^xsd:string . 
      ?author rdfs:label ?authorLabel . filter(lang(?authorLabel)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat2 . 
      ?stat2 ps:P2093 ?authorLabel. 
      ?stat2 pq:P1545 "1"^^xsd:string .
    }

    OPTIONAL {?item p:P50 ?stat3 . 
      ?stat3 ps:P50 ?author2. 
      ?stat3 pq:P1545 "2"^^xsd:string . 
      ?author2 rdfs:label ?author2Label . filter(lang(?author2Label)="en")  
    }

    OPTIONAL {?item p:P2093 ?stat4 . 
      ?stat4 ps:P2093 ?author2Label. 
      ?stat4 pq:P1545 "2"^^xsd:string .
    }

    OPTIONAL {?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en") }
    OPTIONAL {?item wdt:P1433/rdfs:label ?publishedIn . filter(lang(?publishedIn)="en") }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node .
             ?pub_date_node wikibase:timePrecision "9"^^xsd:integer .
             ?pub_date_node wikibase:timeValue ?date9 . 
             BIND(YEAR(?date9) as ?year) }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node2 .
             ?pub_date_node2 wikibase:timePrecision "10"^^xsd:integer .
             ?pub_date_node2 wikibase:timeValue ?date10 . 
             BIND(YEAR(?date10) as ?year) 
             BIND(MONTH(?date10) as ?month_int_) 
             ?month_ p:P279 ?month_stat . 
             ?month_stat ps:P279 wd:Q18602249.
             BIND(xsd:string(?month_int_) as ?month_int)
             ?month_stat pq:P1545 ?month_int .
             ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }

    OPTIONAL {?item p:P577/psv:P577 ?pub_date_node3 .
              ?pub_date_node3 wikibase:timePrecision "11"^^xsd:integer .
              ?pub_date_node3 wikibase:timeValue ?date11 . 
              BIND(YEAR(?date11) as ?year) 
              BIND(MONTH(?date11) as ?month_int_) 
              BIND(DAY(?date11) as ?day)
              ?month_ p:P279 ?month_stat . 
              ?month_stat ps:P279 wd:Q18602249.
              BIND(xsd:string(?month_int_) as ?month_int)
              ?month_stat pq:P1545 ?month_int .
              ?month_ rdfs:label ?month . filter(lang(?month)="en")  
              }
  } 
}       
    OPTIONAL {?item wdt:P2093 ?authorP2093 . }
  } group by ?item 
}  BIND((?countP50 + ?countP2093) AS ?authors)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?author") v12("?author2") v4("?author2Label"):::projected v7("?authorLabel"):::projected v28("?authorP2093") v26("?authorP50") v30("?authors"):::projected v29("?countP2093") v27("?countP50") v18("?date10") v24("?date11") v15("?date9") v28("?day"):::projected v5("?desc_en") v6("?item"):::projected v3("?itemLabel"):::projected v1("?month"):::projected v20("?month_") v28("?month_int"):::projected v28("?month_int_") v21("?month_stat") v14("?pub_date_node") v17("?pub_date_node2") v23("?pub_date_node3") v2("?publishedIn"):::projected v8("?stat") v10("?stat2") v11("?stat3") v13("?stat4") v28("?year"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) a8((" ")) a9((" ")) a10((" ")) a11((" ")) a12((" ")) c4(["wd:Q30"]):::iri c6(["wd:Q13442814"]):::iri c21(["10^^xsd:integer"]):::literal c25(["11^^xsd:integer"]):::literal c24(["wd:Q18602249"]):::iri c10(["1"]):::literal c14(["2"]):::literal c19(["9^^xsd:integer"]):::literal f0[["not "]] subgraph f0e0["Exists Clause"] e0f0[["?desc_en = 'en'"]] e0f0 --> e0v1 e0v2 --"schema:description"--> e0v1 e0v1("?desc_en"):::projected e0v2("?item"):::projected end f0--EXISTS--> f0e0 f0 --> v5 f0 --> v6 f0 --> c2 f1[["?desc_en = 'en'"]] f1 --> v5 v6 --"schema:description"--> v5 v6 --"p:direct/P921"--> c4 v6 --"p:direct/P31"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v8 v8 --"p:statement/P50"--> v9 v8 --"p:qualifier/P1545"--> c10 v9 --"rdfs:label"--> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v10 v10 --"p:statement/P2093"--> v7 v10 --"p:qualifier/P1545"--> c10 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v11 v11 --"p:statement/P50"--> v12 v11 --"p:qualifier/P1545"--> c14 v12 --"rdfs:label"--> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v13 v13 --"p:statement/P2093"--> v4 v13 --"p:qualifier/P1545"--> c14 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v3 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P1433".-> a1 a1 --"rdfs:label"--> v2 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a2 a2 --"p:statement/value/P577"--> v14 v14 --"wikibase:timePrecision"--> c19 v14 --"wikibase:timeValue"--> v15 bind2[/"year-from-dateTime(?date9)"/] v15 --o bind2 bind2 --as--o v28 end subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a3 a3 --"p:statement/value/P577"--> v17 v17 --"wikibase:timePrecision"--> c21 v17 --"wikibase:timeValue"--> v18 bind3[/"year-from-dateTime(?date10)"/] v18 --o bind3 bind3 --as--o v28 bind4[/"month-from-dateTime(?date10)"/] v18 --o bind4 bind4 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind5[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind5 bind5 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a4 a4 --"p:statement/value/P577"--> v23 v23 --"wikibase:timePrecision"--> c25 v23 --"wikibase:timeValue"--> v24 bind6[/"year-from-dateTime(?date11)"/] v24 --o bind6 bind6 --as--o v28 bind7[/"month-from-dateTime(?date11)"/] v24 --o bind7 bind7 --as--o v28 bind8[/"day-from-dateTime(?date11)"/] v24 --o bind8 bind8 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind9[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind9 bind9 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end f10[["not "]] subgraph f10e1["Exists Clause"] e1f0[["?desc_en = 'en'"]] e1f0 --> e1v1 e1v2 --"schema:description"--> e1v1 e1v1("?desc_en"):::projected e1v2("?item"):::projected end f10--EXISTS--> f10e1 f10 --> v5 f10 --> v6 f10 --> c2 f11[["?desc_en = 'en'"]] f11 --> v5 v6 --"schema:description"--> v5 v6 --"p:direct/P921"--> c4 v6 --"p:direct/P31"--> c6 subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v8 v8 --"p:statement/P50"--> v9 v8 --"p:qualifier/P1545"--> c10 v9 --"rdfs:label"--> v7 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v10 v10 --"p:statement/P2093"--> v7 v10 --"p:qualifier/P1545"--> c10 end subgraph optional11["(optional)"] style optional11 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v11 v11 --"p:statement/P50"--> v12 v11 --"p:qualifier/P1545"--> c14 v12 --"rdfs:label"--> v4 end subgraph optional12["(optional)"] style optional12 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v13 v13 --"p:statement/P2093"--> v4 v13 --"p:qualifier/P1545"--> c14 end subgraph optional13["(optional)"] style optional13 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v3 end subgraph optional14["(optional)"] style optional14 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P1433".-> a5 a5 --"rdfs:label"--> v2 end subgraph optional15["(optional)"] style optional15 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a6 a6 --"p:statement/value/P577"--> v14 v14 --"wikibase:timePrecision"--> c19 v14 --"wikibase:timeValue"--> v15 bind12[/"year-from-dateTime(?date9)"/] v15 --o bind12 bind12 --as--o v28 end subgraph optional16["(optional)"] style optional16 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a7 a7 --"p:statement/value/P577"--> v17 v17 --"wikibase:timePrecision"--> c21 v17 --"wikibase:timeValue"--> v18 bind13[/"year-from-dateTime(?date10)"/] v18 --o bind13 bind13 --as--o v28 bind14[/"month-from-dateTime(?date10)"/] v18 --o bind14 bind14 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind15[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind15 bind15 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end subgraph optional17["(optional)"] style optional17 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a8 a8 --"p:statement/value/P577"--> v23 v23 --"wikibase:timePrecision"--> c25 v23 --"wikibase:timeValue"--> v24 bind16[/"year-from-dateTime(?date11)"/] v24 --o bind16 bind16 --as--o v28 bind17[/"month-from-dateTime(?date11)"/] v24 --o bind17 bind17 --as--o v28 bind18[/"day-from-dateTime(?date11)"/] v24 --o bind18 bind18 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind19[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind19 bind19 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end subgraph optional18["(optional)"] style optional18 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P50".-> v26 end bind21[/"count(?authorP50)"/] v26 --o bind21 bind21 --as--o v27 f22[["not "]] subgraph f22e2["Exists Clause"] e2f0[["?desc_en = 'en'"]] e2f0 --> e2v1 e2v2 --"schema:description"--> e2v1 e2v1("?desc_en"):::projected e2v2("?item"):::projected end f22--EXISTS--> f22e2 f22 --> v5 f22 --> v6 f22 --> c2 f23[["?desc_en = 'en'"]] f23 --> v5 v6 --"schema:description"--> v5 v6 --"p:direct/P921"--> c4 v6 --"p:direct/P31"--> c6 subgraph optional19["(optional)"] style optional19 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v8 v8 --"p:statement/P50"--> v9 v8 --"p:qualifier/P1545"--> c10 v9 --"rdfs:label"--> v7 end subgraph optional20["(optional)"] style optional20 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v10 v10 --"p:statement/P2093"--> v7 v10 --"p:qualifier/P1545"--> c10 end subgraph optional21["(optional)"] style optional21 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P50".-> v11 v11 --"p:statement/P50"--> v12 v11 --"p:qualifier/P1545"--> c14 v12 --"rdfs:label"--> v4 end subgraph optional22["(optional)"] style optional22 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P2093".-> v13 v13 --"p:statement/P2093"--> v4 v13 --"p:qualifier/P1545"--> c14 end subgraph optional23["(optional)"] style optional23 fill:#bbf,stroke-dasharray: 5 5; v6 -."rdfs:label".-> v3 end subgraph optional24["(optional)"] style optional24 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P1433".-> a9 a9 --"rdfs:label"--> v2 end subgraph optional25["(optional)"] style optional25 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a10 a10 --"p:statement/value/P577"--> v14 v14 --"wikibase:timePrecision"--> c19 v14 --"wikibase:timeValue"--> v15 bind24[/"year-from-dateTime(?date9)"/] v15 --o bind24 bind24 --as--o v28 end subgraph optional26["(optional)"] style optional26 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a11 a11 --"p:statement/value/P577"--> v17 v17 --"wikibase:timePrecision"--> c21 v17 --"wikibase:timeValue"--> v18 bind25[/"year-from-dateTime(?date10)"/] v18 --o bind25 bind25 --as--o v28 bind26[/"month-from-dateTime(?date10)"/] v18 --o bind26 bind26 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind27[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind27 bind27 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end subgraph optional27["(optional)"] style optional27 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:P577".-> a12 a12 --"p:statement/value/P577"--> v23 v23 --"wikibase:timePrecision"--> c25 v23 --"wikibase:timeValue"--> v24 bind28[/"year-from-dateTime(?date11)"/] v24 --o bind28 bind28 --as--o v28 bind29[/"month-from-dateTime(?date11)"/] v24 --o bind29 bind29 --as--o v28 bind30[/"day-from-dateTime(?date11)"/] v24 --o bind30 bind30 --as--o v28 v20 --"p:P279"--> v21 v21 --"p:statement/P279"--> c24 bind31[/"http://www.w3.org/2001/XMLSchema#string(?month_int_)"/] v28 --o bind31 bind31 --as--o v28 v21 --"p:qualifier/P1545"--> v28 v20 --"rdfs:label"--> v1 end subgraph optional28["(optional)"] style optional28 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:direct/P2093".-> v28 end bind33[/"count(?authorP2093)"/] v28 --o bind33 bind33 --as--o v29 bind34[/"?countP50 + ?countP2093"/] v27 --o bind34 v29 --o bind34 bind34 --as--o v30