User talk:Vicarage

From Wikidata
Jump to navigation Jump to search

Royal Navy ships where vessel_class has no_value[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 ps:P31 wd:Q3114762.
      ?item p:P137 ?statement.
      ?statement (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS { ?item p:P289 ?statement1. }
      MINUS { ?item rdf:type wdno:P289. }
    }
  }
}
Try it!

Aliases[edit]

Good morning. I was just wondering why you were removing aliases from ship items? Any reasonable aliases should ideally be left because the aid searching. — Martin (MSGJ · talk) 07:55, 19 July 2022 (UTC)Reply[reply]

The aliases were very inconsistent, being pennant numbers, names without the HMS, names with a year, even nicknames. I was removing all except actual ship names in other services. If its judged that a particular pattern, like X for HMS X", or DD-123 they could all be all be reintroduced systematically. I would also like to get ship names correctly documented, see the wikidata chat, and the best source of those is a cleaned alias list. I worry that having "Blenheim" as an alias for HMS Blenheim would clutter searches, and its easy enough for a searcher to add the HMS prefix if looking for a ship. I am making sure the descriptions are very clear, so searching should be much easier for similar ships of the same name. Vicarage (talk) 08:23, 19 July 2022 (UTC)Reply[reply]

Castleton[edit]

SELECT DISTINCT ?item ?itemLabel ?itemAltLabel
WHERE {
  hint:Query hint:optimizer "None".
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Search";
                    wikibase:endpoint "www.wikidata.org";
                    mwapi:srsearch "USS Aaron Ward (DF-132)".
    ?item wikibase:apiOutputItem mwapi:title .
  }
 FILTER EXISTS
  {
    { ?item rdfs:label ?text }
    UNION
    { ?item schema:description ?text }
    UNION
    { ?item skos:altLabel ?text }
    FILTER CONTAINS(?text, "HMS Castleton")
  }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

Aaron Ward[edit]

SELECT DISTINCT ?item ?itemLabel ?itemAltLabel
WHERE {
  hint:Query hint:optimizer "None".
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Search";
                    wikibase:endpoint "www.wikidata.org";
                    mwapi:srsearch "USS Aaron Ward (DF-132)".
    ?item wikibase:apiOutputItem mwapi:title .
  }
 FILTER EXISTS
  {
    { ?item rdfs:label ?text }
    UNION
    { ?item schema:description ?text }
    UNION
    { ?item skos:altLabel ?text }
    FILTER CONTAINS(?text, "HMS Castleton")
  }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

should be a shipwreck[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P625 ?statement0.
      ?statement0 ps:P625 _:anyValueP625.
      ?item p:P137 ?statement1.
      ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q11446.
      MINUS {
        ?item p:P31 ?statement3.
        ?statement3 (ps:P31/(wdt:P279*)) wd:Q852190.
      }
    }
  }
}
Try it!

Not in a vessel class[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 ps:P31 wd:Q161705.
      ?item p:P137 ?statement1.
      ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
      minus {
        ?item p:P289 ?statement .
        minus { ?statement a wdno:P289 . }
      }
    }
  }
}
Try it!

wikipedia articles[edit]

SELECT ?ship ?shipLabel ?article WHERE {

    ?ship wdt:P137 wd:Q172771 . # ship
    ?article schema:about ?ship .
    ?article schema:isPartOf <https://en.wikipedia.org/>.

    SERVICE wikibase:label {
       bd:serviceParam wikibase:language "en"
    }
}
Try it!

frigate properties[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription ?service_entry ?service_retirement ?subclassLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      ?item p:P137 ?statement1.
      ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P279 ?statement2.
      ?statement2 (ps:P279/(wdt:P279*)) wd:Q161705.
    }
  }
  OPTIONAL { ?item wdt:P729 ?service_entry. }
  OPTIONAL { ?item wdt:P730 ?service_retirement. }
  OPTIONAL { ?item wdt:P279 ?subclass. }
}
Try it!

no operator[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P279 ?statement0.
      ?statement0 (ps:P279/(wdt:P279*)) wd:Q2811.
      MINUS {
        ?item p:P137 ?statement1.
        ?statement1 (ps:P137/(wdt:P279*)) _:anyValueP137.
      }
    }
  }
}
Try it!
SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      MINUS {
        ?item p:P137 ?statement1.
        ?statement1 (ps:P137/(wdt:P279*)) _:anyValueP137.
      }
    }
  }
}
Try it!

still has country of registry[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription ?vessel_classLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P8047 ?statement1.
      ?statement1 (ps:P8047/(wdt:P279*)) _:anyValueP8047.
    }
  }
  OPTIONAL { ?item wdt:P289 ?vessel_class. }
}
Try it!


??[edit]

SELECT DISTINCT ?item ?itemLabel ?vessel_class ?vessel_classLabel ?operator1 ?operator1Label WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P289 ?statement0.
      ?statement0 (ps:P289/(wdt:P279*)) _:anyValueP289.
      ?item p:P137 ?operator.
      ?operator (ps:P137/(wdt:P279*)) wd:Q172771.
    }
  }
  OPTIONAL { ?item wdt:P137 ?operator1. }
  OPTIONAL { ?item wdt:P289 ?vessel_class. }
}
Try it!

battleship AltLabels[edit]

SELECT DISTINCT ?item ?itemLabel ?itemAltLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P289 ?statement0.
      ?statement0 (ps:P289/(wdt:P279*)) wd:Q182531.
    }
  }
}
Try it!


Minesweepers looking for ([edit]

SELECT DISTINCT ?item ?itemLabel ?itemAltLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P289 ?statement0.
      ?statement0 (ps:P289/(wdt:P279*)) wd:Q202527.
    }
  }
}
Try it!

museum ship location[edit]

SELECT ?ship ?shipLabel ?shipDescription ?coordinates WHERE {
  ?ship wdt:P625 ?coordinates.
  {
    ?ship p:P31 ?statement0.
    ?statement0 (ps:P31/(wdt:P279*)) wd:Q575727.
  }
  UNION
  {
    ?ship p:P366 ?statement1.
    ?statement1 (ps:P366/(wdt:P279*)) wd:Q575727.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

shipyard indirect location[edit]

SELECT ?organisation ?organisationLabel ?location ?locationLabel ?coordinates WHERE {
  ?organisation wdt:P131 ?location;
    wdt:P31 wd:Q190928.
  ?location wdt:P625 ?coordinates.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

navy indirect location[edit]

SELECT ?organisation ?organisationLabel ?location ?locationLabel ?coordinates WHERE {
  ?organisation wdt:P159 ?hq;
    wdt:P31 wd:Q4508.
  ?hq wdt:P131 ?location.
  ?location wdt:P625 ?coordinates.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

Royal Navy shipwrecks[edit]

SELECT DISTINCT ?ship ?shipLabel ?coordinates WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?ship WHERE {
      ?ship p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      {
        ?ship p:P31 ?statement1.
        ?statement1 (ps:P31/(wdt:P279*)) wd:Q852190.
      }
      UNION
      {
        ?ship p:P366 ?statement2.
        ?statement2 (ps:P366/(wdt:P279*)) wd:Q852190.
      }    
    }  
  }
  OPTIONAL { ?ship wdt:P625 ?coordinates. }
}
Try it!

UK shipyards[edit]

SELECT DISTINCT ?ship ?shipLabel ?coordinates WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?ship WHERE {
      ?ship p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q190928.
      ?ship p:P17 ?statement1.
      ?statement1 (ps:P17/(wdt:P279*)) wd:Q145.
    }
  }
  OPTIONAL { ?ship wdt:P625 ?coordinates. }
}
Try it!


Fixme[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      ?item p:P137 ?statement1.
      ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
    }
  }
}
Try it!
SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS {
        ?item p:P289 ?statement1.
        ?statement1 (ps:P289/(wdt:P279*)) _:anyValueP289.
      }
    }
  }
}
Try it!

inception present

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P571 ?statement_1.
      ?statement_1 psv:P571 ?statementValue_1.
      ?statementValue_1 wikibase:timeValue ?P571_1.
    }
  }
}
Try it!
SELECT DISTINCT ?item ?itemLabel ?itemAltLabel ?itemDescription ?vessel_classLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P8047 ?statement1.
      ?statement1 (ps:P8047/(wdt:P279*)) _:anyValueP8047.
    }
  }
  OPTIONAL { ?item wdt:P289 ?vessel_class. }
}
Try it!

dates of battles for ships[edit]

SELECT ?ship ?shipLabel ?conflict ?conflictLabel ?timeLabel WHERE {
  ?ship wdt:P607 ?conflict;
    wdt:P289 wd:Q2240070.
  ?conflict wdt:P585 ?time.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
}
Try it!

dates of battles[edit]

SELECT DISTINCT ?item ?itemLabel ?pointintime ?starttime ?endtime WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q1261499.
    }
    LIMIT 100
  }
  OPTIONAL { ?item wdt:P585 ?pointintime. }
  OPTIONAL { ?item wdt:P580 ?starttime. }
  OPTIONAL { ?item wdt:P582 ?endtime. }
}
Try it!

warship entries changed within 1 day[edit]

SELECT ?item ?itemLabel ?change
WHERE {
  ?item p:P31 ?statement0.
  ?statement0 (ps:P31/(wdt:P279*)) wd:Q3114762.
  ?item schema:dateModified ?change .
    FILTER(BOUND(?change) && DATATYPE(?change) = xsd:dateTime).
    # not in the future, and not more than 1 day ago
    BIND(NOW() - ?change AS ?distance).
    FILTER(0 <= ?distance && ?distance < 1).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }             
} ORDER BY DESC(?change)
Try it!

Fortifications within 20km from Dover Castle[edit]

SELECT ?place ?placeLabel ?placeDescription ?location WHERE {
  wd:Q950970 wdt:P625 ?targetLoc . 
  SERVICE wikibase:around { 
      ?place wdt:P625 ?location . 
      bd:serviceParam wikibase:center ?targetLoc . 
      bd:serviceParam wikibase:radius "20" . 
      bd:serviceParam wikibase:distance ?dist.
  } 
  # Is a fortification but not a hillfort
  FILTER EXISTS { ?place wdt:P31/wdt:P279* wd:Q57821.
    MINUS {
      ?place wdt:P31/wdt:P279* wd:Q744099.
    }
  }
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en-GB,en" . 
  }
} ORDER BY ASC(?dist)
Try it!

Hugo award winners and their years[edit]

With work

SELECT DISTINCT ?item ?itemLabel ?winner ?winnerLabel ?pointintime ?forwork WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?winner ?pointintime ?forwork WHERE {
      ?item wdt:P279 wd:Q188914;
      p:P1346 [ ps:P1346 ?winner ; pq:P585 ?pointintime; pq:P1686 ?forwork].
    }
  }
}
Try it!

without work

SELECT DISTINCT ?item ?itemLabel ?winner ?winnerLabel ?pointintime WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?winner ?pointintime WHERE {
      ?item wdt:P279 wd:Q188914;
      p:P1346 [ ps:P1346 ?winner ; pq:P585 ?pointintime].
    }
  }
}
Try it!

Award details[edit]

SELECT ?item ?itemLabel ?fan ?countryLabel ?conferredLabel ?organiserLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q107581015.
    }
    LIMIT 100
  }
OPTIONAL {?item wdt:P9307 ?fan.}
OPTIONAL {?item wdt:P17 ?country.}
OPTIONAL {?item wdt:P1027 ?conferred.}
OPTIONAL {?item wdt:P664 ?organiser.}
}
Try it!

With Fancyclopedia but without SFE[edit]

SELECT DISTINCT ?item ?itemLabel ?fancy WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P9307 ?statement0.
      ?statement0 (ps:P9307) _:anyValueP9307.
      MINUS {
        ?item p:P5357 ?statement1.
        ?statement1 (ps:P5357) _:anyValueP5357.
      }
    }
  }
  OPTIONAL {?item wdt:P9307 ?fancy.}
}
Try it!

RN ships with no launch date[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS {
        ?item p:P793 ?statement1.
        ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
      }
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q3114762.
    }
  }
}
Try it!

RN ships without a vessel class[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P31 ?statement1.
      ?statement1 (ps:P31/(wdt:P279*)) wd:Q1229765.
      MINUS {
        ?item p:P31 ?statement2.
        ?statement2 (ps:P31/(wdt:P279*)) wd:Q974686.
      }
      MINUS {
        ?item p:P289 ?statement3.
        ?statement3 (ps:P289/(wdt:P279*)) _:anyValueP289.
      }
    }
  }
}
Try it!

Three Decks URL for ship classes[edit]

SELECT DISTINCT ?item ?itemLabel ?source ?url WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?source ?url WHERE {
      ?item p:P31 ?statement1.
      ?statement1 (ps:P31/(wdt:P279*)) wd:Q559026.
      ?item wdt:P1343 wd:Q68966143;
      p:P1343 [ ps:P1343 ?source ; pq:P2699 ?url].
    }
  }
}
Try it!

UK Fortifications with TripAdvisor but without official website[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q57821.
      ?item p:P17 ?statement1.
      ?statement1 (ps:P17/(wdt:P279*)) wd:Q145.
      ?item p:P3134 ?statement2.
      ?statement2 (ps:P3134) _:anyValueP3134.
      MINUS {
        ?item p:P856 ?statement3.
        ?statement3 (ps:P856) _:anyValueP856.
      }
    }
  }
}
Try it!

ship classes that end with s[edit]

SELECT ?item ?label
WHERE
{
  ?item wdt:P31 wd:Q559026;
         rdfs:label ?label.
  FILTER(LANG(?label) = "en").
  FILTER(STRENDS(?label, "s")).
}
Try it!

ship classes that contain a ([edit]

SELECT ?item ?label ?description
WHERE
{
      ?item p:P137 ?statement2.
      ?statement2 (ps:P137/(wdt:P279*)) wd:Q172771.
  ?item wdt:P31 wd:Q559026;
         schema:description ?description;
         rdfs:label ?label.
  FILTER(LANG(?label) = "en").
  FILTER(CONTAINS(?label, "(")).
}
Try it!

RN operated with 19 in name[edit]

SELECT ?item ?label
WHERE
{
  ?item p:P137 ?statement1.
  ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
  ?item rdfs:label ?label.
  FILTER(LANG(?label) = "en").
  FILTER(CONTAINS(?label, "19")).
}
Try it!

Ships with launch dates[edit]

SELECT DISTINCT ?item ?itemLabel ?launchdate WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?launchdate WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
        ?item p:P793 ?statement1.
        ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
        ?statement1 pq:P585 ?launchdate.
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q3114762.
    }
  }
}
Try it!

First rate ships without Three Decks ship id[edit]

SELECT DISTINCT ?item ?itemLabel ?launchdate WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?launchdate WHERE {
      #?item p:P137 ?statement0.
      #?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P793 ?statement1.
      ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
      ?statement1 pq:P585 ?launchdate.
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q892367.
      MINUS {
        ?item p:P11085 ?statement3.
        ?statement3 (ps:P11085) _:anyValueP11085.
      }
        
    }
  }
}
Try it!

Royal Navy ship classes after 1707 without country of origin[edit]

SELECT DISTINCT ?item ?itemLabel ?P729_1 WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?P729_1 WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item p:P729 ?statement_1.
      ?statement_1 psv:P729 ?statementValue_1.
      ?statementValue_1 wikibase:timePrecision ?precision_1.
      hint:Prior hint:rangeSafe "true"^^xsd:boolean.
      FILTER(?precision_1 >= 9 )
      ?statementValue_1 wikibase:timeValue ?P729_1.
      hint:Prior hint:rangeSafe "true"^^xsd:boolean.
      FILTER(?P729_1 >= "+1707-00-00T00:00:00Z"^^xsd:dateTime)
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q19832479.
      MINUS {
        ?item p:P137 ?statement3.
        ?statement3 (ps:P137/(wdt:P279*)) wd:Q11220.
      }
      MINUS {
        ?item p:P495 ?statement4.
        ?statement4 (ps:P495/(wdt:P279*)) _:anyValueP495.
      }
    }
  }
}
Try it!

Find country of shipyard that built a ship[edit]

SELECT DISTINCT ?item ?itemLabel ?shipyardLabel ?country ?countryLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?country ?shipyard WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      MINUS {
        ?item p:P495 ?statement1.
        ?statement1 (ps:P495/(wdt:P279*)) _:anyValueP495.
      }
      ?item wdt:P176 ?shipyard.
      ?shipyard wdt:P17 ?country.
    }
  }
}
Try it!

Sub Brit described by URLs[edit]

SELECT DISTINCT ?item ?itemLabel ?url WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?url WHERE {
      ?item p:P1343 ?statement0.
      ?statement0 (ps:P1343/(wdt:P279*)) wd:Q10683167.
      ?item wdt:P1343 wd:Q10683167;
      p:P1343 [ ps:P1343 ?source ; pq:P2699 ?url].
    }
  }
}
Try it!

Open museums in historic county of Kent[edit]

SELECT DISTINCT ?organisation ?organisationLabel  ?county ?countyLabel WHERE {
   ?organisation wdt:P31/wdt:P279* wd:Q33506.
   ?organisation wdt:P17 wd:Q145 .
   OPTIONAL {?organisation wdt:P7959 ?county1. }
   OPTIONAL {?organisation wdt:P131/wdt:P7959 ?county2. }
   BIND(COALESCE(?county1,?county2) as ?county)
   FILTER(?county IN (wd:Q67479626))
   MINUS {
   ?organisation p:P576 ?statement_2.
   ?statement_2 psv:P576 ?statementValue_2.
   ?statementValue_2 wikibase:timeValue ?P576_2.
   }
   MINUS {
   ?organisation p:P3999 ?statement_3.
   ?statement_3 psv:P3999 ?statementValue_3.
   ?statementValue_3 wikibase:timeValue ?P3999_2.
   } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". } 
}
Try it!

or

SELECT distinct ?organisation ?organisationLabel ?location ?locationLabel ?tag
WHERE {
  { ?organisation wdt:P31/wdt:P279* wd:Q33506 .
    ?organisation wdt:P131 ?location .
    ?organisation wdt:P7959 wd:Q67479626 . 
    bind("Kent (stated on item)" as ?tag) .
  } # option A, it's in the historic county
  union
  { ?organisation wdt:P31/wdt:P279* wd:Q33506 .
    ?organisation wdt:P131 ?location . ?location wdt:P7959 wd:Q67479626 . 
    filter not exists { ?organisation wdt:P7959 wd:Q67479626 } . # not option A
    filter not exists { ?location wdt:P7959 ?elsewhere . filter (?elsewhere != wd:Q67479626) } # not option C
    bind("Kent (deduced via location)" as ?tag) .
  } # option B, it's in somewhere in historic Kent but not tagged as Kent itself, and no other historic county
  union
  { ?organisation wdt:P31/wdt:P279* wd:Q33506 .
    ?organisation wdt:P131 ?location . ?location wdt:P7959 wd:Q67479626 . 
    ?location wdt:P7959 ?elsewhere . filter (?elsewhere != wd:Q67479626) .
    filter not exists { ?organisation wdt:P7959 wd:Q67479626 } . # not option A
    bind("Maybe (location is somewhere which was partly in Kent)" as ?tag) 
  } # option C, it's in somewhere in historic Kent and another historic county
  
  filter not exists { ?organisation wdt:P576 ?closed }
  filter not exists { ?organisation wdt:P3999 ?closed }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }

} order by ?organisationLabel
Try it!

Vicarage (talk) 10:53, 7 November 2022 (UTC)Reply[reply]

fortifications with rejected in description[edit]

SELECT ?item ?label ?description
WHERE
{
      ?item p:P17 ?statement2.
      ?statement2 (ps:P17/(wdt:P279*)) wd:Q145.
  ?item wdt:P31 wd:Q57821;
         schema:description ?description;
         rdfs:label ?label.
  FILTER(LANG(?description) = "en").
  FILTER(CONTAINS(?description, "rejected")).
}
Try it!

Vicarage (talk) 18:12, 24 November 2022 (UTC)Reply[reply]

battleships without a vessel_class, even a null one[edit]

As documented at https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Novalue

SELECT ?item ?itemLabel 
WHERE 
{
  ?item p:P31/ps:P31/wdt:P279* wd:Q182531.
  filter not exists {?item a wdno:P289.}
  filter not exists {?item p:P289 [].}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
}
Try it!

Vicarage (talk) 12:08, 27 November 2022 (UTC)Reply[reply]

Royal Navy ships without vessel_class after 1900[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS {
        ?item p:P289 ?statement1.
        ?statement1 (ps:P289/(wdt:P279*)) _:anyValueP289.
      }
      ?item p:P729 ?statement_2.
      ?statement_2 psv:P729 ?statementValue_2.
      ?statementValue_2 wikibase:timePrecision ?precision_2.
      hint:Prior hint:rangeSafe "true"^^xsd:boolean.
      FILTER(?precision_2 >= 9 )
      ?statementValue_2 wikibase:timeValue ?P729_2.
      hint:Prior hint:rangeSafe "true"^^xsd:boolean.
      FILTER(?P729_2 >= "+1901-00-00T00:00:00Z"^^xsd:dateTime)
      ?item p:P31 ?statement3.
      ?statement3 (ps:P31/(wdt:P279*)) wd:Q1229765.
  filter not exists {?item a wdno:P289.}
  filter not exists {?item p:P289 [].}
    }
  }
}
Try it!

Vicarage (talk) 11:33, 28 November 2022 (UTC)Reply[reply]

Castles that are different to disambiguation pages[edit]

SELECT DISTINCT ?item ?itemLabel ?different ?differentLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }
  {
    SELECT DISTINCT ?item ?different WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q23413.
      ?item p:P17 ?statement1.
      ?statement1 (ps:P17/(wdt:P279*)) wd:Q145.
      ?item wdt:P1889 ?different.
      ?different p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q4167410
    }
  }
}
Try it!

Vicarage (talk) 20:30, 2 December 2022 (UTC)Reply[reply]

Imported from Canmore[edit]

SELECT ?item ?label ?description
WHERE
{
  ?item wdt:P31 wd:Q852190;
         schema:description ?description;
         rdfs:label ?label.
  FILTER(LANG(?description) = "en").
  FILTER(CONTAINS(?description, " imported from Canmore")).
  FILTER(LANG(?label) = "en").
  FILTER(CONTAINS(?label, "Sms")).
}
Try it!

Vicarage (talk) 11:17, 5 December 2022 (UTC)Reply[reply]

ships without service entry[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      ?item p:P495 ?statement1.
      ?statement1 (ps:P495/(wdt:P279*)) wd:Q145.
      MINUS {
        ?item p:P729 ?statement_2.
        ?statement_2 psv:P729 ?statementValue_2.
        ?statementValue_2 wikibase:timeValue ?P729_2.
      }
    }
  }
}
Try it!

Vicarage (talk) 11:19, 5 December 2022 (UTC)Reply[reply]

Castles heritage registers found dynamically[edit]

SELECT DISTINCT ?castleLabel ?registerLabel ?link WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?castle ?register ?link WHERE {
      ?register wdt:P31/wdt:P279* wd:Q18618628.
      ?register wdt:P17 wd:Q145.
      ?register wdt:P1630 ?URLprefix. 
      ?register wikibase:directClaim ?pred .
      ?castle wdt:P31/wdt:P279* wd:Q23413.
      ?castle wdt:P7959 wd:Q67479626.
      ?castle ?pred ?entry .
      BIND(URI(REPLACE(?URLprefix, "\\$1", STR(?entry))) AS ?link)
    }
  }
}
Try it!

Vicarage (talk) 21:26, 10 December 2022 (UTC)Reply[reply]

Forts with wikimedia but no photos[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
      ?item p:P17 ?statement1.
      ?statement1 (ps:P17/(wdt:P279*)) wd:Q145.
      MINUS {
        ?item p:P18 ?statement2.
        ?statement2 (ps:P18) _:anyValueP18.
      }
      ?item p:P373 ?statement3.
      ?statement3 (ps:P373) _:anyValueP373.
    }
  }
}
Try it!

Vicarage (talk) 18:47, 23 January 2023 (UTC)Reply[reply]

Fortifications changed in the last 2 days[edit]

SELECT ?item ?itemLabel ?change
WHERE {
  ?item wdt:P31/wdt:P279* wd:Q57821.
  MINUS {?item wdt:P31/wdt:P279* wd:Q744099.}
  ?item schema:dateModified ?change .
    FILTER(BOUND(?change) && DATATYPE(?change) = xsd:dateTime).
    # not in the future, and not more than 2 days ago
    BIND(NOW() - ?change AS ?distance).
    FILTER(0 <= ?distance && ?distance < 2).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en-GB,en". }             
} ORDER BY DESC(?change)
Try it!

Vicarage (talk) 21:32, 17 February 2023 (UTC)Reply[reply]

Offical names for compromised ships[edit]

SELECT DISTINCT ?item ?itemLabel ?name WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
  {
    SELECT DISTINCT ?item ?name WHERE {
      ?item wdt:P31 wd:Q11446.
      ?item rdfs:label ?label. FILTER (lang(?label) = "en")
      OPTIONAL {
        ?item wdt:P1448 ?officialname.
      }
      BIND(COALESCE(?officialname,?label) AS ?name)
    }
  }
}
Try it!

Vicarage (talk) 09:59, 17 April 2023 (UTC)Reply[reply]

Ship classes mislabelled as ships[edit]

SELECT DISTINCT ?item ?itemLabel ?name WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
  {
    SELECT DISTINCT ?item ?name WHERE {
      ?item wdt:P31/wdt:P279* wd:Q11446.
      ?item rdfs:label ?label. FILTER (lang(?label) = "en")
      FILTER(CONTAINS(?label, "class")).
      OPTIONAL {
        ?item wdt:P1448 ?officialname.
      }
      BIND(COALESCE(?officialname,?label) AS ?name)
    }
  }
}
Try it!

Vicarage (talk) 15:51, 18 April 2023 (UTC)Reply[reply]

Ship names with '('[edit]

SELECT DISTINCT ?item ?itemLabel ?name ?classLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en"}
  {
    SELECT DISTINCT ?item ?name ?class WHERE {
      ?item wdt:P31 wd:Q11446.
      ?item rdfs:label ?label. FILTER (lang(?label) = "en")
      OPTIONAL {
        ?item wdt:P1448 ?officialname.
      }
      BIND(COALESCE(?officialname,?label) AS ?name)
      FILTER(CONTAINS(?name, "(")).
      OPTIONAL { ?item wdt:P289 ?class.}
    }
    #LIMIT 100
  }
}
Try it!

Vicarage (talk) 23:28, 28 April 2023 (UTC)Reply[reply]

Fortifications that are not part of a larger fortification (not working)[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item wdt:P31/wdt:P279* wd:Q57821.
      ?item wdt:P17 wd:Q145.
      MINUS {
        ?item p:P361 ?partof.
        ?partof ps:P361/wdt:P31/wdt:P279* wd:Q57821.
        MINUS {
          ?partof wdt:P31 wd:Q1516079.
        }
      }
      MINUS {
        ?item wdt:P31 wd:Q1516079.
      }
      ?item rdfs:label ?name. 
      FILTER (lang(?name) = "en")
      FILTER(CONTAINS(?name, "Brougham")).
    }
  }
}
Try it!

Vicarage (talk) 10:42, 1 May 2023 (UTC)Reply[reply]

Ship pennant edits[edit]

Hello! Regarding your recent edits like this and this, I'm assuming this was some kind of script error? Huntster (t @ c) 17:19, 9 May 2023 (UTC)Reply[reply]

Oops, yes, I'm doing about 1000 copying from aliases, and the regexp must have got confused. I've fixed those examples, and will do a final check Vicarage (talk) 17:32, 9 May 2023 (UTC)Reply[reply]
Thanks! And yes, there are several dozen in the same group that are likewise affected. Huntster (t @ c) 17:55, 9 May 2023 (UTC)Reply[reply]
Fixed it, thanks for pointing it out Vicarage (talk) 18:40, 9 May 2023 (UTC)Reply[reply]

Cor, there were a lot! I wish quickstatments had spotted my obvious syntax error. Anyway, all fixed now. see

SELECT DISTINCT ?item ?itemLabel ?itemAltLabel ?pennant WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?pennant WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q11220.
      {
        ?item p:P879 ?statement1.
        ?statement1 (ps:P879) _:anyValueP879.
      }
      ?item p:P31 ?statement2.
     ?statement2 (ps:P31/(wdt:P279*)) wd:Q3114762.
    ?item wdt:P879 ?pennant.
  ?item schema:dateModified ?change .
    FILTER(BOUND(?change) && DATATYPE(?change) = xsd:dateTime).
    # not in the future, and not more than 1 day ago
    BIND(NOW() - ?change AS ?distance).
    FILTER(0 <= ?distance && ?distance < 1).
    }
  }
Try it!

}

Thanks for pointing it out Vicarage (talk) 18:27, 9 May 2023 (UTC)Reply[reply]

Royal Navy vessels called ships, when they could be more specific[edit]

SELECT DISTINCT ?item ?itemLabel ?classtype ?classLabel ?classtypeLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?class ?classtype WHERE {
      ?item wdt:P137  wd:Q172771.
      ?item wdt:P31 wd:Q11446.
      ?item p:P289 ?statement1.
      ?statement1 ps:P289 ?class.
      ?class wdt:P279 ?classtype.
      #?item wdt:P31 wd:Q11446.
      #?item p:P289 ?statement2.
      #?statement2 (ps:P289/(wdt:P279*)) _:anyValueP289.
    }
  }
}
Try it!
sed -Ee 's`http://www.wikidata.org/entity/(Q[0-9]*),([^,]*),http://www.wikidata.org/entity/(Q[0-9]*),([^,]*),([^,]*)`-\1|P31|Q11446 /*\2 ship*/\n\1|P31|\3 /*\2 \5*/`' | query.csv Vicarage (talk) 06:05, 10 May 2023 (UTC)Reply[reply]

Royal Navy ships without vessel_class, including no_value, optional inception or launch date[edit]

SELECT DISTINCT ?item ?label ?date WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?label ?date WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      ?item wdt:P31 wd:Q11446;
         schema:description ?description;
         rdfs:label ?label.
      OPTIONAL {?item wdt:P571 ?inception}
      OPTIONAL {?item p:P793 ?statement1. ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
                ?statement1 pq:P585 ?launchdate}
      BIND(COALESCE(?launchdate,?inception) as ?date)
  FILTER(LANG(?label) = "en").
  FILTER(CONTAINS(?label, "HMS")).
      MINUS {
        ?item p:P289 ?statement2.
        ?statement2 (ps:P289/(wdt:P279*)) _:anyValueP289.
      }
    }
  }
}
Try it!

Vicarage (talk) 22:53, 10 May 2023 (UTC)Reply[reply]

Royal Navy ships with no launch date[edit]

SELECT DISTINCT ?item ?itemLabel ?article WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?article WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS {
        ?item p:P793 ?statement1.
        ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
      }
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q11446.
      ?article schema:about ?item .
      ?article schema:isPartOf <https://en.wikipedia.org/>.
    }
  }
}
Try it!

with their wikipedia article, so script

cat nolaunch.csv | sed -Ee 's`http://www.wikidata.org/entity/(Q[0-9]*),([^,]*),.*wiki/(.*)`curl --silent "https://en.wikipedia.org/wiki/Special:Export/\3"  | grep -i "Ship launched" | sed -Ee \x27s\`.*=.*([0-9]{4})\`\1|P793|Q596643|P585|+\\1-00-00T00:00:00Z\/9 /* \2 */\`\x27 | grep P793`' > commands

produces commands to add the missing launch dates, at year level

Vicarage (talk) 09:37, 14 May 2023 (UTC)Reply[reply]

ships without launch dates[edit]

SELECT DISTINCT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P137 ?statement0.
      ?statement0 (ps:P137/(wdt:P279*)) wd:Q172771.
      MINUS {
        ?item p:P793 ?statement1.
        ?statement1 (ps:P793/(wdt:P279*)) wd:Q596643.
      }
      ?item p:P31 ?statement2.
      ?statement2 (ps:P31/(wdt:P279*)) wd:Q177597.
    }
  }
}
Try it!

Vicarage (talk) 11:02, 14 May 2023 (UTC)Reply[reply]

Forts with English and any possible foreign names[edit]

SELECT DISTINCT ?item ?itemLabel ?en_label ?label WHERE {
  SELECT DISTINCT ?item ?en_label (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label) WHERE {
    ?item p:P31 ?statement0.
    ?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
    OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
    OPTIONAL {?item rdfs:label ?item_label}
    #?item wdt:P17 wd:Q794.
  }
  GROUP BY ?item ?en_label
}
Try it!

Martello Tower checks[edit]

SELECT DISTINCT ?item ?itemLabel ?itemDescription ?locationLabel ?describedLabel ?coords ?gridref WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?conservation ?location ?inception ?end ?use ?gridref ?coords ?described ?ordinal WHERE {
      ?item wdt:P31 wd:Q91285. 
      OPTIONAL {?item wdt:P31 wd:Q91285; 
        p:P31 [pq:P1545 ?ordinal]}
      ?item wdt:P17 wd:Q145.
      OPTIONAL {?item wdt:P5816 ?conservation}
      OPTIONAL {?item wdt:P131 ?location}
      OPTIONAL {?item wdt:P571 ?inception}
      OPTIONAL {?item wdt:P571 ?inception}
      OPTIONAL {?item wdt:P576 ?end}
      OPTIONAL {?item wdt:P613 ?gridref}
      OPTIONAL {?item wdt:P625 ?coords}
      OPTIONAL {?item wdt:P366 ?use}
      #OPTIONAL {?item wdt:P7959 ?county}
      OPTIONAL {?item wdt:P18 ?image}
      OPTIONAL {?item wdt:P1343 ?described}
    }
  }
}
Try it!

Vicarage (talk) 15:33, 21 July 2023 (UTC)Reply[reply]

fortifications that have tripadvisor ids with English and foreign labels[edit]

SELECT DISTINCT ?item ?itemLabel ?en_label ?label WHERE {
  SELECT DISTINCT ?item ?en_label (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label) WHERE {
    ?item p:P31 ?statement0.
    #?statement0 (ps:P31/(wdt:P279*)) wd:Q1785071.
    #?statement0 (ps:P31/(wdt:P279*)) wd:Q91122.
    ?statement0 (ps:P31/(wdt:P279*)) wd:Q16748868.
    OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
    OPTIONAL {?item rdfs:label ?item_label}
    #?item wdt:P17 wd:Q794.
      ?item p:P3134 ?statement2.
      ?statement2 (ps:P3134) _:anyValueP3134.
  }
  GROUP BY ?item ?en_label
}
Try it!

Vicarage (talk) 08:44, 24 July 2023 (UTC)Reply[reply]

Fortifications with a commons category but no image[edit]

SELECT ?item ?itemLabel ?comm ?p373 ?cat ?image WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  #?item wdt:P17 wd:Q142.

  {?comm schema:about ?item ; schema:isPartOf <https://commons.wikimedia.org/> .}
  #BIND(replace(wikibase:decodeUri(SUBSTR(STR(?comm), 45)),"_"," ") AS ?comm_decode)
  #?item wdt:P373 ?p373 .
  
 #bind(COALESCE(?comm_decode, ?p373) as ?cat) .
 VALUES ?trida { wd:Q1785071 wd:Q23413 wd:Q56344492}     # fort, castle, battery
 ?item wdt:P31 ?trida.  
     MINUS { ?item wdt:P18 ?image } .
  }
Try it!

Vicarage (talk) 17:19, 24 July 2023 (UTC)Reply[reply]

Brazillian/Soviet warships with official name by preference[edit]

SELECT DISTINCT ?item ?itemLabel ?label WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?label WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q3114762.
      VALUES ?navies { wd:Q1750688 wd:Q796754}
      ?item wdt:P137  ?navies.
      OPTIONAL {?item wdt:P1448 ?officialname}
      OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
      BIND(COALESCE (?officialname, ?en_label) AS ?label)
    }
  }
}
Try it!

download query.csv then

sed -Ee 's`http://www.wikidata.org/entity/(Q[0-9]*),Japanese submarine (.*),(.*)`\1|P1448|mul:"\2" /* \3 */`' query.csv
| grep Japan Vicarage (talk) 20:12, 24 July 2023 (UTC)Reply[reply]

Royal Navy ship classes without a named_after, with the ships that are part of the class, and match the name[edit]

SELECT DISTINCT ?item ?itemLabel ?ship ?shipLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?namedafter ?class ?ship ?shipLabel WHERE {
      ?item wdt:P31 wd:Q559026;
      rdfs:label ?itemlabel.
      MINUS {?item wdt:P138 ?namedafter.    
      ?namedafter wdt:P289 ?class.}
      ?item wdt:P137 wd:Q172771.
      ?ship wdt:P289 ?item;
      rdfs:label ?shiplabel.
      FILTER(LANG(?shiplabel) = "en").
      BIND (SUBSTR(?shiplabel,4) AS ?shiplabel1)
      FILTER (CONTAINS(?itemlabel, ?shiplabel1))
    }
  }
}
Try it!

Vicarage (talk) 09:25, 8 August 2023 (UTC)Reply[reply]

Polish Fort Tour[edit]

SELECT DISTINCT ?item ?itemLabel ?label ?coords WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?label ?coords WHERE {
      VALUES ?item {wd:Q50774 wd:Q9363193 wd:Q9261647 wd:Q2560386 wd:Q2560391 
                    wd:Q33308522 wd:Q9261564 wd:Q33308551
                    wd:Q6424065 wd:Q104731 wd:Q160556 wd:Q5606 wd:Q41599
                    wd:Q313960 wd:Q123511 wd:Q1792 wd:Q110011}
      ?item wdt:P625 ?coords.
    }
  }
}
Try it!

Vicarage (talk) 12:54, 13 August 2023 (UTC)Reply[reply]

Forts with 2 coordinates mentioned, sorted by distance apart[edit]

SELECT ?fort ?fortLabel ?location1 ?location2 ?distance
WHERE 
{
  ?fort wdt:P31 wd:Q1785071.
  ?fort wdt:P625 ?location1.
  ?fort wdt:P625 ?location2.
  BIND(geof:distance(?location1, ?location2) as ?distance).
  
  # deduplicate (by picking location1 to be either east or exactly north of location2)
  FILTER (
    geof:longitude(?location1) < geof:longitude($location2)
    || (
      geof:longitude(?location1) = geof:longitude($location2)
      && geof:latitude(?location1) < geof:latitude($location2)
    )
  ).

  # locations must be different
  FILTER (?distance > 0).
  
  # maximum distance
  FILTER (?distance < 100).
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?distance

Forts claimed to be different, by distance apart[edit]

SELECT ?fort1 ?fort1Label ?fort2 ?fort2Label ?location1 ?location2 ?distance
WHERE 
{
  ?fort1 wdt:P31/wdt:P279* wd:Q1785071.
  ?fort1 wdt:P625 ?location1.
  ?fort1 wdt:P1889 ?fort2.
  #?fort1 wdt:P1889 ?fort2.
  ?fort2 wdt:P31/wdt:P279* wd:Q1785071.
  ?fort2 wdt:P625 ?location2.
  BIND(geof:distance(?location1, ?location2) as ?distance). 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?distance
Try it!
Vicarage (talk) 14:41, 21 August 2023 (UTC)Reply[reply]

lead ships that don't mention it in their vessel_class[edit]

SELECT DISTINCT ?item ?itemLabel ?named ?namedLabel ?roleLabel ?classLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?named ?class ?role WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q559026.
      ?item p:P137 ?statement1.
      ?statement1 (ps:P137/(wdt:P279*)) wd:Q172771.
        ?item wdt:P138 ?named.
        #?named wdt:P289 ?class;
        #?statement2 (ps:P138/(wdt:P279*)) _:anyValueP138.
      ?named wdt:P31/wdt:P279* wd:Q1229765.
      #OPTIONAL {?named p:P289 [ ps:P289 ?class ; pq:P2868 ?role]. FILTER (?role != wd:Q2095057)}
      OPTIONAL {?named p:P289 [ ps:P289 ?class ; pq:P2868 ?role]}
      
      MINUS { ?item wdt:P31 wd:Q21514702}
  }
}
Try it!
Vicarage (talk) 07:10, 1 September 2023 (UTC)Reply[reply]

Portugese Fortification Map[edit]

SELECT DISTINCT ?item ?itemLabel ?coords WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item ?coords WHERE {
      ?item p:P31 ?statement0.
      ?statement0 (ps:P31/(wdt:P279*)) wd:Q57821.
      {?item wdt:P17  wd:Q45} 
      UNION 
      {?item wdt:P17  wd:Q29}
      ?item wdt:P625 ?coords.
    }
  }
}
Try it!
Vicarage (talk) 18:51, 5 September 2023 (UTC)Reply[reply]