Jump to content

User:Ranjithsiji/Queries

From Wikidata

Locations in Kerala

[edit]

The following query uses these:

Features: Wikidata SPARQL map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
SELECT DISTINCT ?location ?locationLabel ?coord
WHERE {
  # Get all items located in Kerala or its subdivisions
  ?location wdt:P131* wd:Q1186.
  
  # Must have coordinates
  ?location wdt:P625 ?coord.
  
  # Get labels
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,ml". }
}

Loksabha constituencies in India

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID, dissolved, abolished or demolished date (P576)  View with Reasonator View with SQID
    #Loksabha Constituencies in India
    SELECT ?item ?itemLabel ?itemDescription
    WHERE
    {
      ?item wdt:P31 wd:Q47481352. # Must be a constituency
      ?item wdt:P17 wd:Q668. # Must be in India
      minus {?item wdt:P576 []} . minus { ?item rdfs:label ?il. filter(lang(?il)="ml") }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then default for all languages, then en language
    }
    

Dams in India

[edit]

The following query uses these:

  • Properties: subclass of (P279)  View with Reasonator View with SQID, instance of (P31)  View with Reasonator View with SQID, country (P17)  View with Reasonator View with SQID
    #Dams in India
    SELECT DISTINCT ?item ?itemLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en,ml". }
      {
        SELECT DISTINCT ?item WHERE {
          ?item p:P31 ?statement0.
          ?statement0 (ps:P31/(wdt:P279*)) wd:Q12323.
          ?item p:P17 ?statement1.
          ?statement1 (ps:P17/(wdt:P279*)) wd:Q668.
        }
      }
    }
    

Dams in Kerala

[edit]

The following query uses these:

Actors associated with Mohanlal

[edit]

The following query uses these:

Features: BubbleChart (Q24515280)  View with Reasonator View with SQID

#Actors associated with Mohanlal in FIlms
# ----
#defaultView:BubbleChart
#title:Actors associated with Mohanlal in FIlms
SELECT (COUNT(?movie) AS ?number_movies) 
  ?relatedActor ?relatedActorLabel WHERE {
    VALUES ?actor { wd:Q2050534 }
    ?movie wdt:P161 ?actor, ?relatedActor.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?relatedActor ?actorLabel ?relatedActorLabel
ORDER BY DESC (COUNT(?relatedActor))

Melakartha Ragas in Carnatic Music

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, has use (P366)  View with Reasonator View with SQID
    #Ragas in Carnatic Music
    SELECT ?item ?itemLabel 
    WHERE 
    {
      ?item wdt:P31 wd:Q7410264.
      ?item wdt:P366 wd:Q956883
      SERVICE wikibase:label { bd:serviceParam wikibase:language "ml,en". }
    }
    

Janya Ragas in Carnatic Music

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, has use (P366)  View with Reasonator View with SQID
    #Ragas in Carnatic Music
    SELECT ?item ?itemLabel 
    WHERE 
    {
      ?item wdt:P31 wd:Q3534390.
      ?item wdt:P366 wd:Q956883
      SERVICE wikibase:label { bd:serviceParam wikibase:language "ml,en". }
    }
    

Female Scientists in Wikidata

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, sex or gender (P21)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID
    SELECT ?item ?itemLabel WHERE {
      ?item wdt:P31 wd:Q5;
        wdt:P21 wd:Q6581072;
        wdt:P106 wd:Q901.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    

Women Politicians in Inda

[edit]

The following query uses these:

Country Lists

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID
    # List of countries
    SELECT ?country ?label_en ?label_ml
    WHERE
    {
      ?country wdt:P31 wd:Q6256.
      ?country rdfs:label ?label_en filter (lang(?label_en) = "en").
      ?country rdfs:label ?label_ml filter (lang(?label_ml) = "ml").
    }
    

Missing Labels in a District

[edit]

The following query uses these:

  • Properties: located in the administrative territorial entity (P131)  View with Reasonator View with SQID
    # List of Places
    SELECT ?item ?itemLabel ?itemDescription WHERE {
    ?item wdt:P131 wd:Q2429655.
    
     SERVICE wikibase:label { bd:serviceParam wikibase:language "ml,en". }
     FILTER(NOT EXISTS {
       ?item rdfs:label ?lang_label.
       FILTER(LANG(?lang_label) = "en")
     })
    }
    ORDER BY ?itemLabel
    

US Scientists

[edit]

US citizens whose occupation is a subclass of scientist:

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, country of citizenship (P27)  View with Reasonator View with SQID, occupation (P106)  View with Reasonator View with SQID, subclass of (P279)  View with Reasonator View with SQID
    # List of SCientists
    SELECT ?item ?itemLabel ?article WHERE {
      ?item wdt:P31 wd:Q5.
      ?item wdt:P27 wd:Q30.
      ?item wdt:P106 ?occupation.
      ?occupation wdt:P279 wd:Q901.
      ?article schema:about ?item.
      ?article schema:inLanguage "en".
      ?article schema:isPartOf <https://en.wikipedia.org/>.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    }
    GROUP BY ?item ?itemLabel ?article
    ORDER BY ?itemLabel
    LIMIT 1000
    

Districts in a State of India

[edit]

The following query uses these:

The following query uses these:

Grampanchayats in Kerala

[edit]

The following query uses these:

Municipalities in Kerala

[edit]

The following query uses these:

  • Properties: instance of (P31)  View with Reasonator View with SQID, located in the administrative territorial entity (P131)  View with Reasonator View with SQID
    SELECT ?item ?len ?lml ?district ?dsten ?dstml ?dsthi WHERE {
      ?item wdt:P31 wd:Q15284.
      ?item wdt:P131/wdt:P131* wd:Q1186.
      ?item wdt:P131 ?district.
      OPTIONAL { ?item wdt:P131 ?division. ?division wdt:P31 wd:Q24943410 }
      OPTIONAL { ?item rdfs:label ?Lang. FILTER(LANG(?Lang)="ml") }
      OPTIONAL { ?item rdfs:label ?len. FILTER(LANG(?len)="en") }
      OPTIONAL { ?item rdfs:label ?lml. FILTER(LANG(?lml)="ml") }
      OPTIONAL { ?item schema:description ?den. FILTER(LANG(?den)="en") }
      OPTIONAL { ?item schema:description ?dml. FILTER(LANG(?dml)="ml") }
      OPTIONAL { ?district rdfs:label ?dsten. FILTER(LANG(?dsten)="en") }
      OPTIONAL { ?district rdfs:label ?dstml. FILTER(LANG(?dstml)="ml") }
      OPTIONAL { ?district rdfs:label ?dsthi. FILTER(LANG(?dsthi)="hi") }
    }
    

Temples in Ernakulam without English Labels

[edit]

Used to fill the gaps in labels

# Temples in Ernakulam without English Labels
SELECT ?item ?itemLabel ?qid WHERE 
{
    ?item wdt:P31 wd:Q842402.
  ?item wdt:P131 wd:Q1356097.
  OPTIONAL {
    ?item rdfs:label ?label .
    FILTER(LANG(?label) = 'en') .
  }
  FILTER(!BOUND($label)) .
  BIND (strafter(str(?item), str(wd:)) AS ?qid)
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'ml' }
}
Try it!

Short URL

The qid is filtered with the last bind command.

Tamil films without Malayalam Labels

[edit]

Used to fill the gaps in labels

# Tamil films without malayalam Labels
SELECT ?item ?itemLabel ?dr ?drlabel ?itemDescription ?qid (year(?year) as ?yr ) WHERE 
{
  ?item wdt:P31 wd:Q11424.
  ?item wdt:P364 wd:Q5885.
  ?item wdt:P577 ?year.
  ?item wdt:P57 ?dr
  OPTIONAL {
    ?item rdfs:label ?label .
    ?item rdfs:descriptipn ?desc .
    FILTER(LANG(?desc) = 'ml') .
  }
    OPTIONAL { ?dr rdfs:label ?drlabel. FILTER(LANG(?drlabel)="ml") }

  FILTER(!BOUND($label)) .
  BIND (strafter(str(?item), str(wd:)) AS ?qid)
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
Try it!

Short URL

The qid is filtered with the last bind command.

Malayalam films without Malayalam Labels

[edit]

Used to fill the gaps in labels

# Created by User:Ranjithsiji
# Malayalam films without Malayalam Description in Wikidata
SELECT ?item ?len ?lml ?den ?itemdesc {
  ?item wdt:P31 wd:Q11424.
  ?item wdt:P364 wd:Q36236
  OPTIONAL { ?item rdfs:label ?len. FILTER(LANG(?len)="en") }
  OPTIONAL { ?item schema:description ?den. FILTER(LANG(?den)="en") }
  OPTIONAL { ?item rdfs:label ?lml. FILTER(LANG(?lml)="ml") }
 # FILTER NOT EXISTS { ?item rdfs:label ?lml. FILTER(LANG(?lml)="ml") }
  FILTER(NOT EXISTS {
    ?item schema:description ?itemdesc.
    FILTER(LANG(?itemdesc) = "ml") # with missing Dutch description
  })
  }
Try it!

Short URL

Remove the comment in the query for labels also

Schools in Thrissur District

[edit]

Used to fill the gaps in labels

# Created by User:Jinoy
# Schools in Thrissur District
#defaultView:Map
SELECT ?item ?ilLang ?geo ?U_DISE_code WHERE {
  { ?item wdt:P31 wd:Q9826. }
  UNION
  { ?item wdt:P31 wd:Q64063386. }
  UNION
  { ?item wdt:P31 wd:Q64063317. }
  UNION
  { ?item wdt:P31 wd:Q64062731. }
  ?item (wdt:P131*) wd:Q2429655.
  OPTIONAL {
    ?item rdfs:label ?ilLang.
    FILTER((LANG(?ilLang)) = "ml")
  }
  OPTIONAL { ?item wdt:P625 ?geo. }
  OPTIONAL { ?item wdt:P6391 ?U_DISE_code. }
}
Try it!

Short URL

Schools in Thrissur District

Schools in Alappuzha District

[edit]

Used to fill the gaps in labels

SELECT ?item ?ilml ?ilen ?kscode ?udisecode WHERE {
  { ?item wdt:P31 wd:Q9826. }
  UNION
  { ?item wdt:P31 wd:Q64063386. }
  UNION
  { ?item wdt:P31 wd:Q64063317. }
  UNION
  { ?item wdt:P31 wd:Q64062731. }
  ?item (wdt:P131*) wd:Q928959.
  OPTIONAL {
    ?item rdfs:label ?ilml.
    FILTER((LANG(?ilml)) = "ml")
  }
  OPTIONAL {
    ?item rdfs:label ?ilen
    FILTER((LANG(?ilen)) = "en")
  }
  ?item wdt:P7065 ?kscode.
  ?item wdt:P6391 ?udisecode.
  OPTIONAL {  }
}
Try it!

Short URL

Schools in Alappuzha District

Songs in English published in 1978

[edit]

Used to fill the gaps in labels

#Songs in English in 1978
SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P7937 wd:Q7366. 
  ?item wdt:P407 wd:Q1860.
  ?item wdt:P577 ?pdate.
  FILTER (?pdate = "1978-01-01T00:00:00Z"^^xsd:dateTime) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # Helps get the label in your language, if not, then default for all languages, then en language
}
Try it!

Short URL

Songs in English published in 1978