-- Wikidata Example 1

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX hint: <http://www.bigdata.com/queryHints#>


SELECT * 
WHERE { 
		SERVICE <http://query.wikidata.org/sparql> 
			{ SELECT DISTINCT ?item ?label ?numero (SAMPLE(?image) AS ?image)
			  WHERE {
					  ?item p:P528 ?catalogStatement .
					  ?item rdfs:label ?label . 
					  ?catalogStatement ps:P528 ?numero .
					  ?catalogStatement pq:P972 wd:Q14530 .
					  OPTIONAL {?item wdt:P18 ?image } .

			 		 # SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
				    }
		     GROUP BY ?item ?label ?numero ORDER BY ?numero 			 
           }
	   } ;

-- Live Results Link: https://tinyurl.com/khm8dzt

-- Wikidata & DBpedia Example 2

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX dct: <http://purl.org/dc/terms/> 


SELECT DISTINCT  xsd:string(?label) as ?name?dbpediaID ?item  as ?wikidataID 
             ?description  
WHERE { 
    SERVICE <http://query.wikidata.org/sparql> 
        { 
          SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
          WHERE {
	              ?item p:P528 ?catalogStatement .
	              ?catalogStatement ps:P528 ?numero .
	              ?catalogStatement pq:P972 wd:Q14530 .
	              OPTIONAL {?item wdt:P18 ?pic } .

	             SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
            	}
         GROUP BY ?item ?numero ORDER BY ?numero
        }
		
     SERVICE <http://dbpedia.org/sparql>
             {
	           SELECT DISTINCT ?item ?dbpediaID ?label ?image ?description ?subjectText
	           FROM <http://dbpedia.org>
	           WHERE { ?dbpediaID owl:sameAs ?item ;
	               rdfs:label ?label ;
	               foaf:depiction ?image ;
	               rdfs:comment ?description ;
	               dct:subject [ rdfs:label ?subjectText ] .
	               FILTER (LANG(?label) = "en")
	               FILTER (LANG(?description) = "en")
             }
          }
} ;
   
-- Live Results Link: https://tinyurl.com/k475m7u

--- Federated Query Across DBpedia and Wikidata SPARQL Query Endpoints for PivotViewer

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX dct: <http://purl.org/dc/terms/> 


SELECT DISTINCT ?subjectText ?dbpediaID as ?href xsd:string(?label) as ?name 
             ?description ?item  as ?wikidataID ?dbpediaID ?image ?picture
WHERE { 
    SERVICE <http://query.wikidata.org/sparql> 
        { 
          SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
          WHERE {
	              ?item p:P528 ?catalogStatement .
	              ?catalogStatement ps:P528 ?numero .
	              ?catalogStatement pq:P972 wd:Q14530 .
	              OPTIONAL {?item wdt:P18 ?pic } .

	             SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
            	}
         GROUP BY ?item ?numero ORDER BY ?numero
        }
		
     SERVICE <http://dbpedia.org/sparql>
             {
	           SELECT DISTINCT ?item ?dbpediaID ?label ?image ?description ?subjectText
	           FROM <http://dbpedia.org>
	           WHERE { ?dbpediaID owl:sameAs ?item ;
	               rdfs:label ?label ;
	               foaf:depiction ?image ;
	               rdfs:comment ?description ;
	               dct:subject [ rdfs:label ?subjectText ] .
	               FILTER (LANG(?label) = "en")
	               FILTER (LANG(?description) = "en")
             }
          }
} ;

	
-- Live Result Link: https://tinyurl.com/m4e77nz



-- Adds Names of Entity Types for additional Categorization 	

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX dct: <http://purl.org/dc/terms/> 


SELECT DISTINCT ?dbpediaID as ?href xsd:string(?label) as ?name 
                ?description ?subjectText ?typeName
                ?item  as ?wikidataID ?dbpediaID ?image ?picture
WHERE { 
		SERVICE <http://query.wikidata.org/sparql> 
			{ 
			  SELECT DISTINCT ?item ?numero (SAMPLE(?pic) AS ?picture)
			  WHERE {
					  ?item p:P528 ?catalogStatement .
					  ?catalogStatement ps:P528 ?numero .
					  ?catalogStatement pq:P972 wd:Q14530 .
					  OPTIONAL {?item wdt:P18 ?pic } .

			 		 # SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
				    }
		     GROUP BY ?item ?numero ORDER BY ?numero 			 
	        }
		
	 SERVICE <http://dbpedia.org/sparql>
	         {       
			   SELECT ?item ?dbpediaID ?label ?image ?description ?subjectText ?typeName
              FROM <http://dbpedia.org> 
			   WHERE { ?dbpediaID a [rdfs:label ?typeName] ; 
                                  owl:sameAs ?item ; 
							   	  rdfs:label ?label ; 
								  foaf:depiction ?image;
								  rdfs:comment ?description ;
								  dct:subject [ rdfs:label ?subjectText ] .
							      FILTER (LANG(?label) = "en") 
				                  FILTER (LANG(?typeName) = "en") 
								  FILTER (LANG(?description) = "en") 
			     }
		      }
   } ;
   
-- Live Results Link : https://tinyurl.com/lw3nc3y
   
   
-- Saint-Raymond Museum
-- Shows Empty Solution fields due to missing data in DBpedia

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX dct: <http://purl.org/dc/terms/> 


SELECT DISTINCT ?dbpediaID as ?href xsd:string(?label) as ?name 
           ?description ?subjectText 
           ?item  as ?wikidataID ?dbpediaID ?img ?image
		   
WHERE { 
			SERVICE <http://query.wikidata.org/sparql> 
				{ 
					SELECT DISTINCT ?item ?monarque ?image
						   (CONCAT("http://zone47.com/crotos/?p195=19675&p180=", REPLACE( str(?monarque),"http://www.wikidata.org/entity/Q","")) as ?voir )
					WHERE {
						    ?item wdt:P195 wd:Q1376.                
						    ?item wdt:P180 ?monarque .              
						    ?monarque wdt:P39 wd:Q842606 .
						    OPTIONAL{ ?item wdt:P18 ?image }
						      SERVICE wikibase:label {
						          bd:serviceParam wikibase:language "en" }
									      } 
			    }

			SERVICE <http://dbpedia.org/sparql>
			     {       
				   SELECT ?item ?dbpediaID ?label ?img ?description ?subjectText 
			       FROM <http://dbpedia.org> 
				   WHERE { 
					   		OPTIONAL { ?dbpediaID owl:sameAs ?item ; 
								   	  rdfs:label ?label ; 
									  foaf:depiction ?img;
									  rdfs:comment ?description ;
									  dct:subject [ rdfs:label ?subjectText ] .
								      FILTER (LANG(?label) = "en") 
					                  FILTER (LANG(?typeName) = "en") 
									  FILTER (LANG(?description) = "en") 
								  }
				     }
			      }
		} ;
		
-- Live Results Link: https://tinyurl.com/keb5oyk

-- Tennis

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>

SELECT * 
WHERE {
		SERVICE <http://query.wikidata.org/sparql>  {
														SELECT ?singlesEvent ?singlesEventLabel ?wimbledonEvent ?wimbledonEventLabel 
															   ?date ?winnerItem ?Player_name ?Event ?image ?Playing_Hand ?Country ?enArticle
															   (COUNT(?article) as ?rank) 
														WHERE {
																VALUES ?events {wd:Q16893072 wd:Q16893403}
																?singlesEvent wdt:P31 ?events . 
																?singlesEvent wdt:P361 ?wimbledonEvent .
																?wimbledonEvent wdt:P31 wd:Q41520 .  
																?wimbledonEvent wdt:P582 ?endDate .
																?singlesEvent wdt:P1346 ?winnerItem .
																?winnerItem wdt:P21 ?genderItem .
																OPTIONAL{?winnerItem wdt:P741 ?playingHandItem }
																OPTIONAL{?winnerItem wdt:P27 ?citizenshipItem }
																BIND (if(?genderItem = wd:Q6581072, ?endDate - "P1D"^^xsd:duration, ?endDate ) as ?date )
																BIND (if(?genderItem = wd:Q6581072, "Women's Singles", "Men's Singles") as ?Event)
																OPTIONAL {?winnerItem wdt:P18 ?image }
																OPTIONAL {?article schema:about ?winnerItem } 
																OPTIONAL {?enArticle schema:about ?winnerItem . 
																		  ?enArticle schema:isPartOf <https://en.wikipedia.org/> 
																	     }
																SERVICE wikibase:label {
																bd:serviceParam wikibase:language "en" .
																?wimbledonEvent rdfs:label ?wimbledonEventLabel .
																?singlesEvent rdfs:label ?singlesEventLabel .
																?winnerItem rdfs:label ?Player_name .
																?playingHandItem rdfs:label ?Playing_Hand .
																?citizenshipItem rdfs:label ?Country .}
														      } 
														GROUP BY  ?singlesEvent ?singlesEventLabel ?wimbledonEvent ?wimbledonEventLabel ?date 
														           ?winnerItem ?Player_name ?Event ?image ?Playing_Hand ?Country ?enArticle
														ORDER BY DESC (?rank)
											}
											
	SERVICE <http://dbpedia.org/sparql>
	     {       
		   SELECT ?singlesEvent ?dbpediaEventID ?dbpediaWimbledonEventID ?wimbledonEvent
	       FROM <http://dbpedia.org> 
		   WHERE { 
			   		OPTIONAL { ?dbpediaEventID owl:sameAs ?singlesEvent .
						       ?dbpediaWimbledonEventID owl:sameAs ?wimbledonEvent  . 
						   	  # rdfs:label ?label ; 
							  # foaf:depiction ?img;
							  # rdfs:comment ?description ;
							  # dct:subject [ rdfs:label ?subjectText ] .
						      # FILTER (LANG(?label) = "en") 
			                  # FILTER (LANG(?typeName) = "en") 
							  # FILTER (LANG(?description) = "en") 
						  }
		     }
	      }
} ;

-- Live Results Link: https://tinyurl.com/k3n7o2g

-- Europeana

SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>

SELECT ?work ?dbpediaWorkID ?title ?inception ?precision 
       ?image ?Exhibition_country ?type_of_work 
       ?creator ?genre ?depicting ?material_used
WHERE {
		SERVICE <http://query.wikidata.org/sparql>  {
														SELECT ?work ?title ?inception ?precision 
														       ?image ?Exhibition_country ?type_of_work 
														       ?creator ?genre ?depicting ?material_used
														WHERE {
																{
																	SELECT ?work ?inception ?precision ?exhibitionCountryItem 
																	        ?instanceOfItem  ?creatorItem ?genreItem ?depictingItem 
																			?materialUsedItem (SAMPLE(?image) as ?image) (COUNT(?article) as ?rank)   
																	WHERE {
																			?work wdt:P608 wd:Q20980830.
																			FILTER (?work != wd:Q133575)
																			?work p:P608/pq:P17 ?exhibitionCountryItem.
																			?work p:P571/psv:P571 ?inceptionStatementNode .
																			?inceptionStatementNode wikibase:timeValue ?inception .
																			?inceptionStatementNode wikibase:timePrecision ?precision .
																			OPTIONAL {?work wdt:P18 ?image}
																			OPTIONAL {?article schema:about ?work}
																			OPTIONAL {?work wdt:P31 ?instanceOfItem }
																			OPTIONAL {?work wdt:P170 ?creatorItem }
																			OPTIONAL {?work wdt:P136 ?genreItem }
																			OPTIONAL {?work wdt:P180 ?depictingItem }
																			OPTIONAL {?work wdt:P186 ?materialUsedItem }      
																	      } 
																   GROUP BY ?work ?inception ?precision ?exhibitionCountryItem ?instanceOfItem  
																             ?creatorItem ?genreItem ?depictingItem ?materialUsedItem
															   }
	   
															  SERVICE wikibase:label {
																						  bd:serviceParam wikibase:language 'en' .
																						  ?work rdfs:label ?title .
																						  ?instanceOfItem rdfs:label ?type_of_work .
																						  ?creatorItem rdfs:label ?creator .
																						  ?genreItem rdfs:label ?genre .
																						  ?depictingItem rdfs:label ?depicting .
																						  ?materialUsedItem rdfs:label ?material_used .
																						  ?exhibitionCountryItem rdfs:label ?Exhibition_country .
																					  }
														  }
														ORDER BY DESC (?rank)
													}
													
	SERVICE <http://dbpedia.org/sparql>
	     {       
		   SELECT ?work ?dbpediaWorkID
	       FROM <http://dbpedia.org> 
		   WHERE { 
			   		OPTIONAL { ?dbpediaWorkID owl:sameAs ?work .
						   	  # rdfs:label ?label ; 
							  # foaf:depiction ?img;
							  # rdfs:comment ?description ;
							  # dct:subject [ rdfs:label ?subjectText ] .
						      # FILTER (LANG(?label) = "en") 
			                  # FILTER (LANG(?typeName) = "en") 
							  # FILTER (LANG(?description) = "en") 
						  }
		     }
	      }
	} ;
	
-- Live Results Link: https://tinyurl.com/lkr3gzm


-- Prize Winners


SPARQL

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>

SELECT ?person ?dbpediaID ?place ?dbpediaPlaceID ?longitude ?latitude?name ?coord ?image ?almamater ?article 
WHERE 

{ SERVICE <http://query.wikidata.org/sparql> {
												SELECT ?name ?coord ?image ?almamater ?article ?place ?person
												WHERE {
														?person wdt:P166 wd:Q47170 ;
														        wdt:P69 ?place .
														?place wdt:P625 ?coord
														OPTIONAL{ ?person wdt:P18 ?image }
														OPTIONAL{ ?article schema:about ?person ; schema:isPartOf <https://en.wikipedia.org/> }
														?person rdfs:label ?name filter (lang(?name) = "en")
														?place rdfs:label ?almamater filter (lang(?almamater) = "en")
													  }
										     }
 SERVICE <http://dbpedia.org/sparql> {
 										SELECT ?person ?place ?dbpediaID ?dbpediaPlaceID ?longitude ?latitude
										FROM <http://dbpedia.org>
										WHERE { 
											     ?dbpediaID owl:sameAs ?person  . 
												 ?dbpediaPlaceID owl:sameAs ?place ;
												 		geo:lat ?latitude ;
												        geo:long ?longitude . 
											  }
										      
									 }
 } 
 
 -- Live Results Link: https://tinyurl.com/lodjceo
