Wikidata:WikiProject Malaysia/Query

WikiProject Malaysia
Home Discussion Activity Topic Query Lexeme


This page is for queries or query requests for items related to Malaysia. See also Wikidata:SPARQL query service/queries and Wikidata:SPARQL query service/queries/examples for other query examples.

Do you have other unique queries? Please +new topic.

Need to request a new query? Please ask in the discussion page.

Museums in Malaysia edit

#defaultView:Map
SELECT DISTINCT ?butir ?nama ?gambar ?koord
WHERE
{
 hint:Query hint:optimizer "None" .
 ?butir wdt:P17* wd:Q833 .
 ?butir wdt:P31/wdt:P279* wd:Q33506 .
 OPTIONAL { ?butir wdt:P18 ?gambar . }
 OPTIONAL { ?butir wdt:P625 ?koord . }
 SERVICE wikibase:label {
 bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" .
 ?butir rdfs:label ?nama
 }
}
Try it!

Items by state edit

#defaultView:BarChart
SELECT ?negeriLabel (COUNT(?butir) AS ?items) WHERE {
  ?butir wdt:P17 wd:Q833;
    (wdt:P131/(wdt:P131*)) ?negeri.
  ?negeri wdt:P31 wd:Q15063586.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "ms". }
}
GROUP BY ?negeriLabel
Try it!

Villages in Malaysia edit

SELECT ?kampung ?kampungLabel ?gambar ?koord WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms". }
  ?kampung wdt:P31 wd:Q532.
  ?kampung wdt:P17 wd:Q833.
  OPTIONAL { ?kampung wdt:P18 ?gambar . }
  OPTIONAL { ?kampung wdt:P625 ?koord. }
}
Try it!

People from Seremban edit

SELECT ?orang ?orangLabel ?gambar WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms". }
  ?orang wdt:P31 wd:Q5.
  ?orang wdt:P19 wd:Q847610.
  OPTIONAL { ?orang wdt:P18 ?gambar . }
  ?sitelink schema:isPartOf <https://ms.wikipedia.org/>;
     schema:about ?orang;
}
Try it!

Malaysians by occupation and gender edit

#defaultView:BubbleChart
SELECT ?occupation_ms ?rgb (COUNT(DISTINCT ?person) AS ?personCount) WHERE {
  ?person wdt:P27 wd:Q833;
    wdt:P106 ?occupation;
    wdt:P21 ?gender.
  bind( if(?gender=wd:Q6581097,"3399FF","FF99FF") as ?rgb ) .
  OPTIONAL {?occupation rdfs:label ?occupation_ms filter (lang(?occupation_ms) = "ms")}. 
}
GROUP BY ?occupation_ms ?rgb
ORDER BY DESC(?personCount)
Try it!

Malaysians by given name edit

SELECT ?nameLabel ?number_of_people WHERE {
  {
    SELECT ?name (COUNT(DISTINCT ?person) AS ?number_of_people) WHERE {
      ?person wdt:P31 wd:Q5;
        wdt:P19 ?pob;
        wdt:P735 ?name.
      ?pob wdt:P17 wd:Q833.
    }
    GROUP BY ?name
    ORDER BY DESC (?number_of_people)
    LIMIT 200
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC (?number_of_people)
Try it!

Common ingredient of Malaysian cuisine edit

#defaultView:BubbleChart
#title:Common ingredients of Malaysian cuisine
SELECT ?ingredienteLabel (COUNT (?ingrediente) AS ?count)
WHERE
{
  ?sandwich wdt:P361?/wdt:P279* wd:Q772247;
            wdt:P527 ?ingrediente.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY  ?ingredienteLabel
ORDER BY DESC (?count)
Common ingredients of Malaysian cuisine

Malaysia-related items unavailable in Malay Wikipedia edit

#Malaysian subjects with no Malay article in Wikipedia

SELECT ?item ?itemLabel ?cnt WHERE {
{
  SELECT ?item (COUNT(?sitelink) AS ?cnt) WHERE { 
  ?item wdt:P27|wdt:P205|wdt:P17 wd:Q833 . #Malaysian subjects.
  MINUS {?item wdt:P106 wd:Q488111 .} #Minus occupations that would be inappropriate in most situations.
  MINUS {?item wdt:P106 wd:Q3286043 .}
  MINUS {?item wdt:P106 wd:Q4610556 .}  
  ?sitelink schema:about ?item .
  FILTER NOT EXISTS {
    ?article schema:about ?item .
    ?article schema:isPartOf <https://ms.wikipedia.org/> . #Targeting Wikipedia language where subjects has no article.
  }
  } GROUP BY ?item ORDER BY DESC (?cnt) #Sorted by amount of articles in other languages.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms,en,zh,ta" }  #Service to resolve labels in (fallback) languages: automatic user language, Malay, English, Chinese, Tamil.
} ORDER BY DESC (?cnt)
Try it!

Malay literary works edit

#Karya sastera berbahasa Melayu
SELECT DISTINCT ?butir ?tajuk ?pengarangLabel ?tarikh_terbit
WHERE
{
  ?butir wdt:P31 wd:Q7725634 .
  ?butir wdt:P407 wd:Q9237 .
  OPTIONAL { ?butir wdt:P1476 ?tajuk. }
  OPTIONAL { ?butir wdt:P50 ?pengarang. }
  OPTIONAL { ?butir wdt:P577 ?tarikh_terbit. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" . }
}
ORDER BY ?tajuk ?tarikh_terbit
Try it!

Schools in Malaysia edit

#defaultView:Map
SELECT DISTINCT ?butir ?nama ?gambar ?koord
WHERE
{
 hint:Query hint:optimizer "None" .
 ?butir wdt:P17* wd:Q833 .
 ?butir wdt:P31/wdt:P279* wd:Q3914 .
 OPTIONAL { ?butir wdt:P18 ?gambar . }
 OPTIONAL { ?butir wdt:P625 ?koord . }
 SERVICE wikibase:label {
 bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" .
 ?butir rdfs:label ?nama
 }
}
Try it!

Libraries in Malaysia edit

#defaultView:Map
SELECT DISTINCT ?butir ?nama ?gambar ?koord
WHERE
{
 hint:Query hint:optimizer "None" .
 ?butir wdt:P17* wd:Q833 .
 ?butir wdt:P31/wdt:P279* wd:Q7075 .
 OPTIONAL { ?butir wdt:P18 ?gambar . }
 OPTIONAL { ?butir wdt:P625 ?koord . }
 SERVICE wikibase:label {
 bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" .
 ?butir rdfs:label ?nama
 }
}
Try it!

Railway stations in Malaysia edit

#defaultView:Map
SELECT DISTINCT ?butir ?nama ?gambar ?koord
WHERE
{
 hint:Query hint:optimizer "None" .
 ?butir wdt:P17* wd:Q833 .
 ?butir wdt:P31/wdt:P279* wd:Q55488 .
 OPTIONAL { ?butir wdt:P18 ?gambar . }
 OPTIONAL { ?butir wdt:P625 ?koord . }
 SERVICE wikibase:label {
 bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" .
 ?butir rdfs:label ?nama
 }
}
Try it!

Roads in Malaysia edit

#defaultView:Map
SELECT DISTINCT ?butir ?nama ?gambar ?koord
WHERE
{
 hint:Query hint:optimizer "None" .
 ?butir wdt:P17* wd:Q833 .
 ?butir wdt:P31/wdt:P279* wd:Q34442 .
 OPTIONAL { ?butir wdt:P18 ?gambar . }
 OPTIONAL { ?butir wdt:P625 ?koord . }
 SERVICE wikibase:label {
 bd:serviceParam wikibase:language "[AUTO_LANGUAGE],ms" .
 ?butir rdfs:label ?nama
 }
}
Try it!

Classifier usage in Malay edit

#defaultView:BubbleChart
SELECT ?classifier (group_concat(?lemma; separator="/") as ?lemmas) ?number_of_nouns WHERE {
  {
    SELECT ?classifier (COUNT(DISTINCT ?noun) AS ?number_of_nouns) WHERE {
      ?noun dct:language wd:Q9237;
        wdt:P5978 ?classifier.
    }
    GROUP BY ?classifier
  }
  ?classifier wikibase:lemma ?lemma.
} group by ?classifier ?number_of_nouns
ORDER BY DESC (?number_of_nouns)
Try it!

Tofeiku (talk) 03:57, 5 June 2023 (UTC)Reply