Wikidata:WikiProject Jasmerah/Queries

National Heroes of Indonesia

edit
# National heroes of Indonesia
SELECT *
WHERE {
  ?itemID wdt:P166 wd:Q1369309 . # items with award received National Hero of Indonesia
  OPTIONAL { ?itemID rdfs:label ?labelEN . # English label
             FILTER(LANG(?labelEN)="en") }
  OPTIONAL { ?itemID rdfs:label ?labelID . # Indonesian label
             FILTER(LANG(?labelID)="id") }
}
Try it!

National Heroes of Indonesia and Their Birthdates

edit
# National heroes of Indonesia and their birthdates
SELECT ?itemID ?labelEN ?labelID ?birthdate
WHERE {
  ?itemID wdt:P166 wd:Q1369309 . # items with award received National Hero of Indonesia
  OPTIONAL { ?itemID wdt:P569 ?birthdate } # birthdate information
  OPTIONAL { ?itemID rdfs:label ?labelEN . # English label
             FILTER(LANG(?labelEN)="en") }
  OPTIONAL { ?itemID rdfs:label ?labelID . # Indonesian label
             FILTER(LANG(?labelID)="id") }
}
Try it!

National Heroes of Indonesia and Their Date of Death

edit
# National heroes of Indonesia and their date of death
SELECT ?itemID ?labelEN ?labelID ?deathdate
WHERE {
  ?itemID wdt:P166 wd:Q1369309 . # items with award received National Hero of Indonesia
  OPTIONAL { ?itemID wdt:P570 ?deathdate } # deathdate information
  OPTIONAL { ?itemID rdfs:label ?labelEN . # English label
             FILTER(LANG(?labelEN)="en") }
  OPTIONAL { ?itemID rdfs:label ?labelID . # Indonesian label
             FILTER(LANG(?labelID)="id") }
}
Try it!

National Heroes of Indonesia and Their Ages

edit
# National heroes of Indonesia and their ages (rough approximation based on years)
SELECT ?itemID ?labelID (YEAR(?deathdate)-YEAR(?birthdate) AS ?age)
WHERE {
  ?itemID wdt:P166 wd:Q1369309 . # items with award received National Hero of Indonesia
  ?itemID wdt:P569 ?birthdate . # birthdate information
  ?itemID wdt:P570 ?deathdate . # deathdate information
  OPTIONAL { ?itemID rdfs:label ?labelID . # Indonesian label
             FILTER(LANG(?labelID)="id") }
}
Try it!

National Heroes of Indonesia without Genders

edit
# National heroes of Indonesia without genders
SELECT ?itemID ?labelEN ?labelID ?genderEN
WHERE {
  ?itemID wdt:P166 wd:Q1369309 . # items with award received National Hero of Indonesia
  FILTER NOT EXISTS { ?itemID wdt:P21 ?gender } # without genders
  OPTIONAL { ?itemID rdfs:label ?labelEN . # English label
             FILTER(LANG(?labelEN)="en") }
  OPTIONAL { ?itemID rdfs:label ?labelID . # Indonesian label
             FILTER(LANG(?labelID)="id") }
}
Try it!

Properties of National Heroes of Indonesia

edit
# Properties of national heroes of Indonesia ordered by property frequency
SELECT ?directProp ?pLabel (COUNT(?directProp) AS ?propFreq)
WHERE {
    ?itemID wdt:P166 wd:Q1369309 .  # items with award received National Hero of Indonesia
    {                               # focus on direct properties
      ?itemID ?directProp _:bnode .
      ?prop wikibase:directClaim ?directProp .
      ?prop rdfs:label ?pLabel
      FILTER(LANG(?pLabel)="en")
    }
} GROUP BY ?directProp ?pLabel ORDER BY DESC(?propFreq)
Try it!

Indonesian National Heroes Couples

edit
# Indonesian national heroes whose spouse is also an Indonesian national hero
SELECT *
{   ?person wdt:P166 wd:Q1369309 . # An Indonesian national hero ..
    ?person wdt:P26 ?spouse . # whose spouse ..
    ?spouse wdt:P166 wd:Q1369309 . # is also an Indonesian national hero.
    ?person wdt:P21 wd:Q6581097 . # hack for removing repetitions
    ?person rdfs:label ?labelPerson .
    ?spouse rdfs:label ?labelSpouse .
    FILTER(LANG(?labelPerson)="en" && LANG(?labelSpouse)="en")
}
Try it!

Triple Count of Indonesian National Heroes

edit
# (Direct) Triple Count of Indonesian National Heroes
SELECT ?itemID ?itemIDLabel (COUNT(?directProp) AS ?tripleCount)
WHERE {
    ?itemID wdt:P166 wd:Q1369309 .  # Indonesian national hero
    {                               # focus on direct properties
      ?itemID ?directProp ?directPropValue .
      _:bnode wikibase:directClaim ?directProp .
      ?itemID rdfs:label ?itemIDLabel
      FILTER(LANG(?itemIDLabel)="en")
    }
}
GROUP BY ?itemID ?itemIDLabel ORDER BY DESC(?tripleCount)
Try it!

Indonesian Independence Wars

edit

Warning: This query is still under construction!

SELECT *
WHERE {
  { {?itemID wdt:P31 wd:Q198} # wars
    UNION
    {?itemID wdt:P31 wd:Q180684 } # conflicts
  }
  OPTIONAL { ?itemID rdfs:label ?labelEN . # English label of items
             FILTER(LANG(?labelEN)="en") }
  { ?itemID rdfs:label ?labelID . # Indonesian label must exist and contain Perang
    FILTER(LANG(?labelID)="id" && CONTAINS(LCASE(?labelID),"perang")) }
}
Try it!