Usuario:Rfornas/Taller/TALLER SPARQL

De Wikipedia, la enciclopedia libre


Contacto

Tomás Saorín, Universidad de Murcia, tsp@um.es

Recursos útiles[editar]

Bibliografía, presentaciones, tutoriales, proyectos, etc.

Materiales guía[editar]

Esquemas en-una-página

Bibliografía útil[editar]

Ejemplos SPARQL[editar]

Consultar, consumir, explotar el grafo de conocimiento de Wikidata.

Recuerda que para obtener las etiquetas de los items, debemos añadir en la consulta SPARQL la correspondiente llamada al servicio label de Wikibase. Así siempre que añadamos "Label" a una variable (?itemLabel) nos la presentará bien rotulada:
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en" }

Material de referencia y tutoriales[editar]

Obres de Filippo Lippi[editar]

Pintures de l'autor cronològicament i amb imatges

SELECT ?obra ?obraLabel ?article (YEAR(?DateCrea) AS ?AnneeCrea) ?imagen WHERE {
  ?obra wdt:P170 wd:Q205148;
    wdt:P571 ?DateCrea.
  ?article schema:about ?obra;
    schema:isPartOf <https://it.wikipedia.org/>.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it". }
  OPTIONAL { ?obra wdt:P18 ?imagen. }
}
ORDER BY (?AnneeCrea)


Centenaris[editar]

Guia centenaris 2021

SELECT  ?autorLabel ?article (year(?date) as ?year) WHERE {
  ?autor wdt:P570 ?date .
  ?autor wdt:P106 wd:Q36180 .
  ?article 	schema:about ?autor ;
			schema:isPartOf <https://es.wikipedia.org/> .
  FILTER (datatype(?date) = xsd:dateTime)
  FILTER (year(?date) = 1621)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Batalles[editar]

Batalles entre l'any 950 i l'any 900, per a categoritzar per any de conflicte

select  ?xLabel ?article ?date
where {

# ?x wdt:instància de wd:instància
  ?x wdt:P31 wd:Q178561 .
  ?x wdt:P585 ?date FILTER (YEAR(?date) <= 0950 && YEAR(?date) > 0900) .
  
 ?article 	schema:about ?x ;
			schema:isPartOf <https://es.wikipedia.org/>
 SERVICE wikibase:label {
    bd:serviceParam wikibase:language "es" .
   }
      }
ORDER BY DESC (?date)
LIMIT 20000

Batalles comparatives d'edicions franceses i espanyoles

select  ?xLabel ?articlees ?articlefr ?date
where {

# ?x wdt:instància de wd:instància
  ?x wdt:P31 wd:Q178561 .
  ?x wdt:P585 ?date FILTER (YEAR(?date) <= 974 && YEAR(?date) > 960) .
  
 ?articlefr 	schema:about ?x ;
			schema:isPartOf <https://fr.wikipedia.org/>
     OPTIONAL {?articlees 	schema:about ?x ;
			schema:isPartOf <https://es.wikipedia.org/>}
 SERVICE wikibase:label {
    bd:serviceParam wikibase:language "fr,es" .
   }
      }
ORDER BY ASC (?date)
LIMIT 20000

Escriptors morts en un any[editar]

Escriptors morts o nascuts en un any

SELECT  ?autorLabel ?article (year(?date) as ?year) WHERE {
  ?autor wdt:P570 ?date .
  ?autor wdt:P106 wd:Q36180 .
  ?article 	schema:about ?autor ;
			schema:isPartOf <https://es.wikipedia.org/> .
  FILTER (datatype(?date) = xsd:dateTime)
  FILTER (year(?date) = 2020)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Buscando cosas sobre ... PUENTES[editar]

Vamos a realizar búsquedas sobre PUENTES.

Wikidata Query Service

El punto de acceso interrogable SPARQL está en https://query.wikidata.org/ (SPARQL EndPoint)

Listado inicial de puentes[editar]

Consulta por Q12280 que es puente ... pero también hay tipos

{{SPARQL|query=SELECT ?cosa ?cosaLabel 
WHERE 
{
  ?cosa wdt:P31 wd:Q12280
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Puentes en España[editar]

Añadimos el patrón país (P17) España Q29 Consulta por tipo (P31) Q12280 que es puente ... pero también hay tipos

{{SPARQL|query=SELECT ?cosa ?cosaLabel 
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P17 wd:Q29
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Puentes de todos los tipos en España[editar]

Búsqueda recursos por subclases

{{SPARQL|query=SELECT ?cosa ?cosaLabel ?tipo ?tipoLabel
WHERE 
{
  ?cosa  wdt:P31*/wdt:P279* wd:Q12280 .
  ?cosa wdt:P17 wd:Q29 .
  ?cosa wdt:P31 ?tipo
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}}

Arquitectos de los puentes en España[editar]

Añadimos P84 (arquitecto)

{{SPARQL|query=SELECT ?cosa ?cosaLabel ?arquitecto ?arquitectoLabel
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P17 wd:Q29 .
  ?cosa wdt:P84 ?arquitecto
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Puentes en el mundo de Arquitectos que hayan estudiado en el Politécnico de Zurich[editar]

Añadimos P84 (arquitecto) Añadimos P69 (educado en)

{{SPARQL|query=SELECT ?cosa ?cosaLabel ?arquitecto ?arquitectoLabel
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P84 ?arquitecto .
  ?arquitecto wdt:P69 wd:Q11942
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Premios que han recibido los arquitectos que han hecho puentes en España[editar]

Añadimos premio recibido P166

{{SPARQL|query=SELECT ?arquitecto ?arquitectoLabel ?premio ?premioLabel
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P17 wd:Q29 .
  ?cosa wdt:P84 ?arquitecto .
  ?arquitecto wdt:P166 ?premio
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Ocupación de personas que han recibido premios que tambimén han recibido arquitectos de puentes en España[editar]

Descubrimiento de cosas extrañas

{{SPARQL|query=SELECT ?persona ?personaLabel ?ocupacion ?ocupacionLabel
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P17 wd:Q29 .
  ?cosa wdt:P84 ?arquitecto .
  ?arquitecto wdt:P166 ?premio .
  ?persona wdt:P166 ?premio .
  ?persona wdt:P106 ?ocupacion .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Fotos de puentes del mundo[editar]

Usamos plantilla

{{SPARQL|query=#defaultView:ImageGrid
SELECT ?cosa ?cosaLabel ?image
WHERE 
{
  ?cosa wdt:P31 wd:Q12280 .
  ?cosa wdt:P18 ?image .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Mapa de puentes de todo tipo en España[editar]

Usamos plantilla Map

{{SPARQL|query=#defaultView:Map
SELECT ?cosa ?cosaLabel ?geo
WHERE 
{
  ?cosa  wdt:P31*/wdt:P279* wd:Q12280 .
  ?cosa wdt:P17 wd:Q29 .
  ?cosa wdt:P625 ?geo .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Mapa de puentes de todo tipo que atraviesan el Tajo[editar]

Usamos plantilla Map

{{SPARQL|query=#defaultView:Map
SELECT ?cosa ?cosaLabel ?geo
WHERE 
{
  ?cosa  wdt:P31*/wdt:P279* wd:Q12280 .
  ?cosa wdt:P177 wd:Q14294 .
  ?cosa wdt:P625 ?geo .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Mapa de puentes que cruzan el Tejo, el Nilo y el Missisipí[editar]

Usamos plantilla Map

{{SPARQL|query=#defaultView:Map
SELECT ?cosa ?cosaLabel ?geo
WHERE 
{
  VALUES ?rio {wd:Q14294 wd:Q3392 wd:Q1497} #Rios: Tajo Nilo Missisipi
  ?cosa  wdt:P31*/wdt:P279* wd:Q12280 .
  ?cosa wdt:P177 ?rio .
  ?cosa wdt:P625 ?geo .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

¿En qué paises hay más puentes?[editar]

Gráfico de barras para los 20 países con más puentes. Recursiva por P279 subclase.

{{SPARQL|query=#defaultView:BarChart
SELECT ?paisLabel (COUNT(?item) as ?num)
WHERE {
  ?item wdt:P17 ?pais .
  ?item wdt:P31 ?tipo . # Tipo del item
  ?tipo wdt:P279* wd:Q12280 . # tipo subclase recursiva de PUENTE
  
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en,eu". }
}
GROUP BY ?paisLabel
ORDER BY DESC(?num)
LIMIT 20
}}

¿De qué color es el puente Golden Gate?[editar]

Como existe la propiedad P462 color y sé que el identificador del Golden Gate Q44440

{{SPARQL|query=SELECT ?color ?colorLabel
WHERE {
  wd:Q44440 wdt:P462 ?color
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Listado de colores de puentes[editar]

Ahora podemos probar con P462 qué sabemos sobre los colores de los puentes ...

{{SPARQL|query=SELECT ?item ?itemLabel ?color ?colorLabel
WHERE {
  ?item  wdt:P31*/wdt:P279* wd:Q12280 .
  ?item wdt:P462 ?color
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Material de construcción[editar]

Aunque el color no es lo más relevante. Mejor probamos con "material empleado", que es una propiedad más constructiva (P186).

{{SPARQL|query=SELECT ?item ?itemLabel ?material ?materialLabel
WHERE {
  ?item  wdt:P31*/wdt:P279* wd:Q12280 .
  ?item wdt:P186 ?material
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

¿De qué material están hechos los puentes que cruzan el Tajo?[editar]

Podemos llegar a saber cosas que a Google le cuesta responder (de momento) y además veremos que solo "sabemos" el material de la mitad de los puentes (los que son de piedra)...

{{SPARQL|query=SELECT ?item ?itemLabel ?material ?materialLabel
WHERE {
  ?item  wdt:P31*/wdt:P279* wd:Q12280 .
  ?item wdt:P177 wd:Q14294 .
  OPTIONAL {  ?item wdt:P186 ?material . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
}}

Consultando la ontología (Propiedades, clases)[editar]

Búsquedas para conocer cómo está organizado el conocimiento en Wikidata como ontología, taxonomía, red de conceptos o vocabulario-esquema.

Jerarquía de clases para BOSQUE[editar]

Recorrido de las subclases (P279) a las que pertenece el concepto Bosque (Q4421):

SELECT ?entity ?entityLabel (count(?mid) as ?depth) WHERE {
  wd:Q4421 wdt:P279* ?mid.
  ?mid wdt:P279* ?entity
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} group by ?entity ?entityLabel
order by ?depth

Grafo de vecindad de conceptos de la Pandamia COVID-19[editar]

Plantilla de visualización en grafo.

# Neighbourhood graph of the covid core items
#PREFIX target: <http://www.wikidata.org/entity/Q84263196> # COVID-19 disease
#PREFIX target: <http://www.wikidata.org/entity/Q82069695> # SARS-CoV-2
PREFIX target: <http://www.wikidata.org/entity/Q81068910> # COVID-19 Pandemia 2019-2020
#defaultView:Graph
SELECT ?node ?nodeLabel ?childNode ?childNodeLabel ?rgb WHERE {
  {
    BIND(target: AS ?node)
    ?node ?p ?i.
    ?childNode ?x ?p.
    ?childNode rdf:type wikibase:Property.
    FILTER(STRSTARTS(STR(?i), "http://www.wikidata.org/entity/Q"))
    FILTER(STRSTARTS(STR(?childNode), "http://www.wikidata.org/entity/P"))
   
  }
  UNION
  {
    BIND("EFFBD8" AS ?rgb)
    target: ?p ?childNode.
    ?node ?x ?p.
    ?node rdf:type wikibase:Property.
    FILTER(STRSTARTS(STR(?childNode), "http://www.wikidata.org/entity/Q"))
  }

 MINUS { ?node wdt:P31/wdt:P279* wd:Q51118821} #Exclusión items internos de proyectos Wikimedia
  MINUS { ?childNode wdt:P31/wdt:P279* wd:Q51118821} #Exclusión relaciones internas de proyectos Wikimedia
  MINUS { ?childNode wdt:P31/wdt:P279* wd:Q15138389} #Exclusión relaciones internas de artículos Wikimedia
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}

Otras búsquedas SPARQL[editar]

Personas nacidas en el País Vasco[editar]

Búsqueda recursiva por pertenencia a entidad territorial administrativa P131.

SELECT ?persona ?personaLabel ?lugar
WHERE {
?persona wdt:P19 ?lugar . # lugar de nacimiento
?lugar wdt:P131* wd:Q3995 # situado en la entidad territorial administrativa (recursiva) País Vasco
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}

Listado de géneros literarios[editar]

Búsqueda de tipos y géneros literarios

SELECT ?s ?desc WHERE {
  ?s wdt:P279 wd:Q7725634 .
  OPTIONAL {
      ?s rdfs:label ?desc 
      FILTER (LANG(?desc) = "en").
  }
}

Escritores españoles cuya fecha de nacimiento coincide con el de hoy[editar]

Pues eso

SELECT ?autor ?autorLabel ?date
WHERE 
{
  ?autor wdt:P27 wd:Q29 . #pais español
  ?autor wdt:P106 wd:Q36180 . # autor
  OPTIONAL {?autor wd:Q49757 ?poeta . }
  OPTIONAL {?autor wd:Q487596 ?dramaturgo . }
  OPTIONAL {?autor wd:Q6625963 ?novelista . }
  ?autor p:P569/psv:P569 ?date_node . # node for date of birth
   ?date_node wikibase:timePrecision "11"^^xsd:integer . # date precision = day
   ?date_node wikibase:timeValue ?date . 
   FILTER (day(?date) = day(now())) .  # day of birth date is day of current date
   FILTER (month(?date) = month(now())) . # month of birth date is month of current date
  
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }

}
ORDER BY ?date
LIMIT 100

Escritores del mundo cuya fecha de nacimiento coincide con el de hoy[editar]

Todos los escritores por orden descendente y limitado a 300

SELECT ?autor ?autorLabel ?date
WHERE 
{
  
  ?autor wdt:P106 wd:Q36180 . # autor
  OPTIONAL {?autor wd:Q49757 ?poeta . }
  OPTIONAL {?autor wd:Q487596 ?dramaturgo . }
  OPTIONAL {?autor wd:Q6625963 ?novelista . }
  ?autor p:P569/psv:P569 ?date_node . # node for date of birth
   ?date_node wikibase:timePrecision "11"^^xsd:integer . # date precision = day
   ?date_node wikibase:timeValue ?date . 
   FILTER (day(?date) = day(now())) .  # day of birth date is day of current date
   FILTER (month(?date) = month(now())) . # month of birth date is month of current date
  
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es". }

}

ORDER BY DESC(?date)
LIMIT 300

Escritores nacidos tal dia[editar]

Escriptors nascuts dia assenyalat amb enllaç wiki en espanyol. Codi de mort 570

select  ?autorLabel  (YEAR(?date) as ?year) ?article (DAY(?date) as ?day) (MONTH(?date) as ?month)
where {
 
    {?autor wdt:P31 wd:Q5;    
    wdt:P106 wd:Q36180;  
    wdt:P569 ?date . 
    ?article 	schema:about ?autor ;
			schema:isPartOf <https://es.wikipedia.org/> .
    }
     FILTER (MONTH(?date) = 6 && DAY(?date)=7)
 SERVICE wikibase:label {
    bd:serviceParam wikibase:language "es" .
   }
      }
ORDER BY ?date
LIMIT 10000

Primeras líneas de obras en español[editar]

SELECT ?item ?itemLabel ?inicio ?autorLabel
WHERE 
{
  ?item wdt:P407 wd:Q1321 . #idioma español
  ?item wdt:P50 ?autor . # autor
  ?item wdt:P1922 ?inicio .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}

Dones espanyoles més populars a la wiki[editar]

SELECT distinct ?person ?personLabel ?birthplace ?birthplaceLabel ?article ?linkcount WHERE {
  ?person wdt:P27 wd:Q29 .
  ?person wdt:P19 ?birthplace .
  ?person wdt:P21 wd:Q6581072 .
  ?article 	schema:about ?person ;
			schema:isPartOf <https://es.wikipedia.org/> .
  ?person wikibase:sitelinks ?linkcount .
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],es" .
  }
}
ORDER BY DESC(?linkcount)

Capitales de todos los países de la UE[editar]

SELECT ?country ?countryLabel ?capitalLabel ?population 
WHERE 
{
  ?country wdt:P463 wd:Q458.
  ?country wdt:P36 ?capital.
  ?capital wdt:P1082 ?population.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "   [AUTO_LANGUAGE],en". }
}

Cuadrícula con foto de los premios nobel de física[editar]

#defaultView:ImageGrid
SELECT ?person ?personLabel ?image
WHERE 
{
  ?person wdt:P18 ?image;
          wdt:P166 wd:Q38104.
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Mapa de países que usan el teléfono 112 de emergencias[editar]

#defaultView:Map
SELECT ?country ?countryLabel ?location
WHERE {
 ?country wdt:P2852 wd:Q1061257;
           wdt:P625 ?location.
  
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}


Campos de actividad de Alan Turing[editar]

SELECT ?campo ?campoLabel {
wd:Q7251 wdt:P101 ?campo
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Personas muertas[editar]

SELECT ?entity (year(?date) as ?year) WHERE {
?entity wdt:P570 ?date .
FILTER (datatype(?date) = xsd:dateTime)
FILTER (year(?date) = year(now()))
}
 LIMIT 100

Personas fallecidas en 1937[editar]

SELECT ?autor ?autorLabel (year(?date) as ?year) WHERE {
  ?autor wdt:P570 ?date .
  ?autor wdt:P27 wd:Q29 .
  FILTER (datatype(?date) = xsd:dateTime)
  FILTER (year(?date) = 1937)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Autores españoles que entran en el dominio público este año[editar]

SELECT ?autor ?autorLabel (year(?date) as ?year) WHERE {
  ?autor wdt:P570 ?date .
  ?autor wdt:P27 wd:Q29 .
  ?autor wdt:P106 ?ocupacion .
  ?ocupacion wdt:P279* wd:Q36180 .
         FILTER (datatype(?date) = xsd:dateTime)
         FILTER (year(?date) = 1937)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Creadores españoles que entran en el dominio público[editar]

SELECT ?autor ?autorLabel ?ocupacionLabel (year(?date) as ?year) WHERE {
  ?autor wdt:P570 ?date .
  ?autor wdt:P27 wd:Q29 .
  ?autor wdt:P106 ?ocupacion .
  ?ocupacion wdt:P279* wd:Q482980 .
         FILTER (datatype(?date) = xsd:dateTime)
         FILTER (year(?date) = 1937)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Directores de películas inspiradas en Hamlet[editar]

SELECT ?obra ?obraLabel ?directorLabel ?generoLabel ?year 
WHERE {
?obra wdt:P144 wd:Q41567 .
  ?obra wdt:P577 ?year .
  ?obra wdt:P57 ?director .
  OPTIONAL {?obra wdt:P136 ?genero }
         SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Personajes de obras literarias asesinados y su asesino[editar]

select ?personaje ?personajeLabel ?asesinoLabel Where {
?personaje wdt:P31 wd:Q3658341 .
  ?personaje wdt:P1441 wd:Q8337 .
  ?personaje wdt:P157 ?asesino
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Año de creación de La libertad guiando al pueblo[editar]

SELECT (year(?DateCrea) as ?AnneeCrea) WHERE {
wd:Q29530 wdt:P571 ?DateCrea 
}

Cuadros pintados el mismo año que La Libertad guiando al pueblo[editar]

SELECT ?cuadroLabel ?autorLabel (year(?DateCrea) as ?AnneeCrea)
WHERE {
  wd:Q29530 wdt:P571 ?DateCrea .
  ?cuadro wdt:P571 ?DateCrea .
  ?cuadro wdt:P31 wd:Q3305213 .
  ?cuadro wdt:P170 ?autor .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Cuadros que representan caballos en el barroco[editar]

SELECT ?cuadro ?cuadroLabel ?autorLabel (year(?DateCrea) as ?AnneeCrea)
WHERE {
  ?cuadro wdt:P31 wd:Q3305213 .
       ?cuadro wdt:P571 ?DateCrea .
       ?cuadro wdt:P180 wd:Q726 .
?cuadro wdt:P135 wd:Q37853 .
       ?cuadro wdt:P170 ?autor 
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
}

Personas relevantes nacidas en Londres[editar]

SELECT (COUNT(DISTINCT ?item) AS ?total)
WHERE {
  ?item wdt:P19 wd:Q84
      }

Obras de Vermeer por año de creación[editar]

SELECT ?obra ?obraLabel (year(?DateCrea) as ?AnneeCrea)
WHERE {
  ?obra wdt:P170 wd:Q41264 ;
                  wdt:P571 ?DateCrea.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"  }
} ORDER BY ?AnneeCrea

Gráfico de área de libros por año de publicación y genero en narrativa, desde el año 2000[editar]

Incluye datos de cualificadores

#Libros escritos por año y genero desde 2000
#defaultView:AreaChart
SELECT ?cid (STR(SAMPLE(?year)) AS ?year) (COUNT(*) AS ?count) ?genero WHERE {
   ?pid wdt:P31 wd:Q571;  # libro   
        wdt:P50 ?autor; # autor 
       wdt:P136 ?cid;  # genero
       wdt:P577 ?_date_of_pub. # fecha de publicación
  ?cid wdt:P279* wd:Q1318295.  # tipo de genero narrativo
  ?autor wdt:P27 wd:Q29 # nacionalidad autor España
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
                         ?cid rdfs:label ?genero. }
  BIND ( YEAR(?_date_of_pub) AS ?year )
  FILTER( ?year >= 2000 )
}
GROUP BY ?cid ?genero ?year

Premios recibidos por Muñoz Molina cada año[editar]

Incluye datos de cualificadores

SELECT ?item ?itemLabel (year(?edicion) as ?year) WHERE {
wd:Q450335 p:P166 ?statement .
?statement ps:P166 ?item.
  ?statement pq:P585 ?edicion
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}

Partes de catedrales registradas en Wikidata[editar]

SELECT ?cosaLabel (COUNT(?item) as ?partes)
WHERE 
{
  ?item wdt:P361 ?cosa . #Parte de catedral Notre Dame
  ?cosa wdt:P31 ?catedral .
  ?catedral wdt:P279* wd:Q2977
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
GROUP BY ?cosaLabel
ORDER BY ?partes

Premios ganados por vascos[editar]

Recursiva por P131 entidad territorial y obtención de cualificador P585 Fecha. Premio y año

SELECT ?persona ?personaLabel ?item ?itemLabel (year(?edicion) as ?year) WHERE {
?persona wdt:P19 ?lugar . # lugar de nacimiento
?lugar wdt:P131* wd:Q3995 . # situado en la entidad territorial administrativa (recursiva) País Vasco
  ?persona p:P166 ?statement . #existencia de statement P166 premio recibido
?statement ps:P166 ?item. # Obtención desde el statement del premio recibido
  ?statement pq:P585 ?edicion # Obtención del cualificador P585 Fecha
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en,eu". }
}
ORDER BY ?personaLabel

¿En qué paises hay más puentes?[editar]

Gráfico de barras para los 20 países con más puentes. Recursiva por P279 subclase.

#defaultView:BarChart
SELECT ?paisLabel (COUNT(?item) as ?num)
WHERE {
  ?item wdt:P17 ?pais .
  ?item wdt:P31 ?tipo . # Tipo del item
  ?tipo wdt:P279* wd:Q12280 . # tipo subclase recursiva de PUENTE
  
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en,eu". }
}
GROUP BY ?paisLabel
ORDER BY DESC(?num)
LIMIT 20

Grafo de organizaciones y periodistas[editar]

#Periodistas agrupados por pertenencia de grupos/colectivos/organizaciones
#defaultView:Graph
SELECT ?char ?charLabel ?group ?groupLabel ("7FFF00" as ?rgb)
WHERE {
 ?char wdt:P106 wd:Q1930187 . # ocupación periodista
  ?char wdt:P27 wd:Q29 . # nacionalidad española
  ?char wdt:P463 ?group # member de una organización
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".}
}
<