User:Jarekt/Witkacy queries

KDM+dates

edit
SELECT ?item (YEAR(?date) as ?year) (MONTH(?date) as ?month) (DAY(?date) as ?day) ?dateprecision ?KDM WHERE { 
 ?item wdt:P170 wd:Q381238 .  
 MINUS{ ?item wdt:P31 wd:Q3658341 .}
 optional{ 
   ?item p:P571/psv:P571 ?timenode .
   ?timenode wikibase:timeValue         ?date.
   ?timenode wikibase:timePrecision     ?dateprecision.
  }
 optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }

}
Try it!

order

edit
SELECT ?item ?Len ?kdm ?kdmn WHERE { 
 ?item wdt:P170 wd:Q381238 .          # Witkacy as creator
 MINUS{ ?item wdt:P31 wd:Q3658341 .}  # no literary characters
 MINUS{ ?item wdt:P31 wd:Q125191 .}   # no photographs
   
 optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?kdm] . }
 optional{ ?item wdt:P156/wdt:P528 ?prev .}            
 optional{ ?item wdt:P155/wdt:P528 ?next .}             
 bind( if( bound(?kdm) && strStarts(str(?kdm), "I "), CONCAT(STR( ?kdm  ), ".5"), 
       if( bound(?next),                              CONCAT(STR( ?next ), ".9"),
       if( bound(?prev),                              CONCAT(STR( ?prev ), ".1"), 
       "Z") ) ) as ?kdmn ) .

 OPTIONAL {
   ?item rdfs:label ?Len 
   FILTER((LANG(?Len)) = "en")
 }
 filter (?item!=wd:Q107095853)
} order by ?kdmn
Try it!

qid-KDM-img

edit
SELECT ?item ?KDM ?img WHERE { 
 ?item wdt:P170 wd:Q381238 .  
 ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] .
 optional{ ?item wdt:P18 ?img. }
} order by ?KDM
Try it!

Prace Witkacego opublikowane w Przekroju

edit
#defaultView:ImageGrid
SELECT ?item ?number ?data ?Lpl ?img WHERE { 
  ?item wdt:P170 wd:Q381238 . 
  ?item p:P1433 [ ps:P1433 wd:Q2114540; pq:P433 ?number ; pq:P577 ?data] .
  OPTIONAL {
   ?item rdfs:label ?Lpl 
   FILTER((LANG(?Lpl)) = "pl")
  }
   optional{ ?item wdt:P18 ?img. }
} order by ?number
Try it!

images

edit

small images

edit
# Federation with correlation - Get height and width for Commons images
# Run this from WCQS - https://commons-query.wikimedia.org/
SELECT ?item ?page ?image ?file ?width ?height
WHERE {
  hint:Query hint:optimizer "None" .
  SERVICE <https://query.wikidata.org/sparql> {
    ?item p:P1433 [ ps:P1433 wd:Q113870515; pq:P304 ?page_ ] ;
      wdt:P18 ?image .
    BIND(xsd:integer(?page_) as ?page) .
  }
  ?file schema:url ?image ;
    schema:height ?height ;
    schema:width ?width .
}
ORDER BY (?width * ?height)
Try it!

no images

edit
SELECT ?item ?itemLabel ?date ?collectionLabel WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P571 ?date .   
 optional{ ?item wdt:P195 ?collection .  }
 MINUS{ ?item wdt:P31 wd:Q3658341 .}  # no literary characters
 MINUS{ ?item wdt:P18 ?img .  }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
Try it!

items without images

edit
SELECT ?item ?itemLabel ?date ?collectionLabel WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P571 ?date .   
 optional{ ?item wdt:P195 ?collection .  }
 MINUS{ ?item wdt:P31 wd:Q3658341 .}  # no literary characters
 MINUS{ ?item wdt:P18 ?img .  }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
Try it!

museum pieces without image

edit
SELECT ?item ?itemLabel ?collectionLabel ?id ?kdm WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item wdt:P195 ?collection . 
 minus {?collection wdt:P31 wd:Q768717 }
 optional{?item wdt:P217 ?id . } 
 optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?kdm] . }
 MINUS{ ?item wdt:P18 [] .  }
 
 FILTER (!wikibase:isSomeValue(?collection))
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by ?collection
Try it!

Muzea

edit
SELECT ?collection ?collectionLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item wdt:P195 ?collection . 
 minus {?collection wdt:P31 wd:Q768717 }

 FILTER (!wikibase:isSomeValue(?collection))
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?collection ?collectionLabel
order by desc(?count)
Try it!

missing fields

edit

missing collection

edit
SELECT ?item  ?img ?KDM ?collection WHERE {
 ?item wdt:P170 wd:Q381238 .  
 ?item wdt:P18 ?img .
 minus{ ?item wdt:P195 ?collection . }   
 minus{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
} order by ?KDM
Try it!

missing P31=pastel

edit
SELECT ?item ?itemLabel ?img WHERE {
 ?item wdt:P170 wd:Q381238 .  
 ?item wdt:P186 wd:Q189085 .  
 ?item wdt:P18 ?img .  
 MINUS{ ?item wdt:P31 wd:Q12043905 .}
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Try it!

missing en descriptions

edit
SELECT ?item   (YEAR(?date) as ?year) ?KDM ?itemDescription WHERE {
 ?item wdt:P170 wd:Q381238 .  
 ?item wdt:P186 wd:Q189085 .  
 ?item wdt:P571 ?date .  
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
 optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }                                       
}
Try it!
edit
SELECT ?item  WHERE {
 ?item wdt:P170 wd:Q381238 .  
 MINUS{ ?item wdt:P31 wd:Q3658341 .}
 #minus{ ?item wdt:P6216 wd:Q19652 }. 
 
 ?item p:P6216 ?statement .
 FILTER NOT EXISTS { ?statement pq:P1001 [] } # exclude if P1001 present
 #FILTER NOT EXISTS { ?statement pq:P459  [] } # exclude if P459  present

}
Try it!

missing references / brakujące źródła

edit
SELECT ?item ?KDM
WHERE {
 ?item wdt:P170 wd:Q381238 .  
 ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM; ] .
 minus { ?item p:P528 [ prov:wasDerivedFrom [ pr:P248 [] ]  ] } .
}
Try it!

missing inscriptions/ brakujące sygnatury

edit

SELECT ?item ?img ?KDM WHERE {

?item wdt:P170 wd:Q381238 .  
optional{ ?item wdt:P18 ?img . }
optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM; ] . }
minus { ?item wdt:P1684 [] } .

}

other

edit

signature with "|"

edit
SELECT ?item  ?ins WHERE {
 ?item wdt:P170 wd:Q381238.
 ?item wdt:P1684 ?ins .  
 FILTER (contains(str(?ins), "|" ))
}
Try it!

genre

edit
SELECT ?item  ?genre ?itemLabel WHERE {
 ?item wdt:P170 wd:Q381238 .    
 optional{ ?item wdt:P136 ?genre .   } 
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

collection->location

edit
SELECT ?item  ?collection ?loc WHERE {
 ?item wdt:P170 wd:Q381238 .    
 ?item wdt:P195 ?collection .    
 minus{ ?item wdt:P276 ?loc .   } 
}
Try it!

main subject

edit
SELECT ?item ?itemLabel  WHERE {
 ?item wdt:P170 wd:Q381238 .    
 ?item wdt:P136 wd:Q134307 .   
 minus {?item wdt:P921 ?depicts .   }
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

copy main subject based on label

edit
SELECT ?label ?subject1Label ?item2 ?subject1  WHERE {
 ?item1 wdt:P170 wd:Q381238 .    
 ?item2 wdt:P170 wd:Q381238 . 
  
 ?item1 wdt:P921 ?subject1 .   
 minus{ ?item2 wdt:P921 ?subject2 . }
 
  ?item1 rdfs:label ?label .
  FILTER(LANG(?label) = 'pl') .
  FILTER(?subject1 != wd:Q381238) .
  
  ?item2 rdfs:label ?label .
  FILTER(LANG(?label) = 'pl') .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Try it!

Different works with the same KDM ID

edit
SELECT ?item1 ?item2 ?id WHERE {
 ?item1 wdt:P170 wd:Q381238 .    
 ?item2 wdt:P170 wd:Q381238 .    
 ?item1 wdt:P528 ?id.
 ?item2 wdt:P528 ?id.
 FILTER(?item1 != ?item2) .
 FILTER(strlen(?id)<=6) .
}
Try it!

publications with Witkacy artworks

edit
SELECT ?pub ?pubLabel (count(?item) as ?count)  WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P1433 ?pub.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" }
} group by ?pub ?pubLabel
order by ?count
Try it!

osoby portretowane

edit
SELECT ?person ?personLabel (count(?item) as ?count)  WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P921 ?person.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" }
} group by ?person ?personLabel
order by desc(?count)
Try it!

survey significant events

edit
SELECT ?event ?eventLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P793 ?event .   
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?event ?eventLabel
Try it!

bad significant events

edit
SELECT ?item WHERE {
  ?item wdt:P170 wd:Q381238 .   
  ?item p:P793 ?statement .
  ?statement pq:P585 ?date1.
  ?statement pq:P585 ?date2.
  Filter (?date1 > ?date2).
}
Try it!
SELECT ?item WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P793 wd:Q9209474 .
}
Try it!


survey medium

edit
SELECT ?med ?medLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P186 ?med .   
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?med ?medLabel
Try it!

survey art shows

edit
SELECT ?item ?itemLabel WHERE {
 ?item wdt:P921 wd:Q381238 .   
 ?item wdt:P31 wd:Q667276  .
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
}
Try it!

self-portraits / autoportrety

edit
SELECT ?item ?KDM ?Lpl ?img WHERE { 
  ?item wdt:P170 wd:Q381238 . 
  ?item wdt:P136 wd:Q192110  . 
  OPTIONAL {
   ?item rdfs:label ?Lpl 
   FILTER((LANG(?Lpl)) = "pl")
  }
   optional{ ?item p:P528 [ pq:P972 wd:Q106425660; ps:P528 ?KDM] . }
   optional{ ?item wdt:P18 ?img. }
  minus{ ?item wdt:P31 wd:Q125191 }
} order by ?KDM
Try it!

auctions

edit

auction houses

edit
SELECT ?loc ?locLabel (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item p:P793 ?statement .
 ?statement pq:P276 ?loc.
 ?statement ps:P793 wd:Q177923
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?loc ?locLabel
order by desc(?count)
Try it!

auction house images by url

edit
SELECT ?item ?img WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P973 ?url .   
 ?item wdt:P18 ?img .  
 FILTER (STRSTARTS(STR(?url), "https://www.sda.pl"))
}
Try it!

auction house images by q-id

edit
SELECT ?item ?img WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P18 ?img .
 ?item p:P793 ?statement .
 ?statement pq:P276 wd:Q503176.  
}
Try it!

catalog auction results

edit
SELECT ?item ?img ?locLabel ?date ?price WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P18 ?img .   
 ?item p:P793 ?statement .
 ?statement pq:P276 ?loc.
 ?statement pq:P585 ?date.
 optional{?statement pq:P2284 ?price.}
 optional{?statement pq:P4775 ?lot.}
 ?statement ps:P793 wd:Q177923
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by desc(?date)
Try it!

catalog auction results in last 3 months

edit
SELECT ?item ?img ?locLabel ?date ?price WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P18 ?img .   
 ?item p:P793 ?statement .
 ?statement pq:P276 ?loc.
 ?statement pq:P585 ?date.
 optional{?statement pq:P2284 ?price.}
 optional{?statement pq:P4775 ?lot.}
 ?statement ps:P793 wd:Q177923
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
    FILTER(BOUND(?date) && DATATYPE(?date) = xsd:dateTime).
    # not in the future, and not more than 90 days ago
    BIND(NOW() - ?date AS ?distance).
    FILTER(0 <= ?distance && ?distance < 90).
} order by desc(?date)
Try it!

most frequently auctioned artworks

edit
SELECT ?item (count(?item) as ?count) (SAMPLE(?img) as ?sampleimg) WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P18 ?img .   
 ?item p:P793 ?statement .
 ?statement ps:P793 wd:Q177923
} group by ?item
order by desc(?count)
Try it!

jak często są prace na aukcjach

edit
SELECT ?count_auctions_per_artwork (count(?item) as ?count_artworks) WHERE {
{SELECT ?item (count(?item) as ?count_auctions_per_artwork) WHERE {
   ?item wdt:P170 wd:Q381238 .   
   ?item p:P793/ps:P793 wd:Q177923
  } group by ?item }
} group by ?count_auctions_per_artwork
order by ?count_auctions_per_artwork
Try it!

mean price per year

edit
SELECT ?year (round(AVG(?price)) as ?mean) WHERE {
 ?item wdt:P170 wd:Q381238 .      
 ?item p:P793 ?statement .
 ?statement pq:P585 ?date.
 ?statement pq:P2284 ?price.
 FILTER ( ! wikibase:isSomeValue(?price))
 BIND ( YEAR(?date) as ?year).
} group by ?year
order by ?year
Try it!

aukcje/ceny/waluty

edit
SELECT ?item ?locLabel ?date ?price ?unitLabel WHERE {
 ?item wdt:P170 wd:Q381238 .   
 ?item wdt:P18 ?img .   
 ?item p:P793 ?statement .
 ?statement pq:P276 ?loc.
 ?statement pq:P585 ?date.
 ?statement pq:P2284 ?price_statement.
 ?statement pqv:P2284 [ wikibase:quantityAmount ?price ; wikibase:quantityUnit ?unit ]  .
 ?statement ps:P793 wd:Q177923
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} order by desc(?date)
Try it!

Statistics

edit

number of works per year

edit
SELECT ?year (count(?item) as ?count) (SAMPLE(?item) as ?sampleitem) WHERE {
 ?item wdt:P170 wd:Q381238 .      
 ?item wdt:P571 ?date.
 BIND ( YEAR(?date) as ?year).
} group by ?year
order by ?year
Try it!

number of works per month

edit
SELECT ?month (count(?item) as ?count) WHERE {
   ?item wdt:P170 wd:Q381238 .   
   ?item p:P571/psv:P571 ?timenode .
   ?timenode wikibase:timeValue ?date.
   ?timenode wikibase:timePrecision ?dateprecision.
   FILTER(?dateprecision > 9).
   Bind(MONTH(?date) as ?month)
} group by ?month
order by ?month
Try it!

number of works per day of the week

edit
SELECT ?mod (count(?item) as ?count) WHERE {
   ?item wdt:P170 wd:Q381238 .   
   ?item p:P571/psv:P571 ?timenode .
   ?timenode wikibase:timeValue ?date.
   ?timenode wikibase:timePrecision ?dateprecision.
   FILTER(?dateprecision = 11).

   BIND (?date - "1900-01-01"^^xsd:date AS ?ndays)
  # Compute modulo by 7 without a modulo operator
  BIND (floor(?ndays - (7 * floor(?ndays/7))) AS ?mod)
} group by ?mod
order by ?mod
Try it!

technique

edit
SELECT ?materialLabel (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .      
 ?item wdt:P186 ?material.
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?materialLabel
order by desc(?count)
Try it!

number of works per year + technique

edit
SELECT ?year ?materialLabel (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .      
 ?item wdt:P571 ?date.
 ?item wdt:P186 ?material.
  VALUES ?material { 
     wd:Q189085
     wd:Q14674
     wd:Q1424515
     wd:Q296955
  } .
  
 BIND ( YEAR(?date) as ?year).
 SERVICE wikibase:label { bd:serviceParam wikibase:language "pl,pl" }
} group by ?year ?materialLabel
order by ?year  ?materialLabel
Try it!
edit

number of items in museums

edit
SELECT (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item wdt:P195 ?collection . 
 minus{ ?collection wdt:P31 wd:Q768717 }

 FILTER (!wikibase:isSomeValue(?collection))
}
Try it!

number of items in named private collections

edit
SELECT (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item p:P195 ?statement . 
 ?statement ps:P195 ?collection .
 ?collection wdt:P31 wd:Q768717 .
 FILTER NOT EXISTS { ?statement pq:P518 wd:Q114187913} # exclude if P1001 for USA present
 FILTER (!wikibase:isSomeValue(?collection))
}
Try it!

number of items in private collections

edit
SELECT (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item p:P195 ?statement.
 ?statement pq:P3831 wd:Q768717 .
 Minus{ ?statement pq:P518 wd:Q114187913 }
}
Try it!

lost works known from photographs

edit
SELECT (count(?item) as ?count) WHERE {
 ?item wdt:P170 wd:Q381238 .     
 ?item p:P195/pq:P828 wd:Q4140840  .
 ?item p:P195/pq:P518 wd:Q114187913   .
}
Try it!