query: SELECT 
    DISTINCT ?item 
    ?article 
  WHERE {
    SERVICE bd:sample { ?pub wdt:P50 ?item. bd:serviceParam bd:sample.limit 42000 }
     {
        ?article schema:about ?item .
        ?article schema:inLanguage "en" .
        FILTER (SUBSTR(str(?article), 1, 25) = "https://en.wikipedia.org/")
    }
      ?work wdt:P2860 ?pub .
      
   OPTIONAL {   
     SELECT ?item ?pageid 
                  ?ns WHERE {
      SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:endpoint "en.wikipedia.org" .
        bd:serviceParam wikibase:api "Generator" .
        bd:serviceParam mwapi:generator "search" .
        bd:serviceParam mwapi:gsrsearch "hastemplate:Scholia" .
        bd:serviceParam mwapi:gsrlimit "max" .
        ?item wikibase:apiOutputItem mwapi:item .
        ?pageid wikibase:apiOutput "@pageid" .
        ?ns wikibase:apiOutput "@ns" .
      }
    } LIMIT 10000
   }
  
    BIND( IF(BOUND(?article),   IF(BOUND(?ns), "ArticleWithScholia" , "ArticleNoScholia" )  ,  "NoArticle"   )  AS ?condition).  
    FILTER (?condition = "ArticleNoScholia")
  }