Template:Unique values

From Wikidata
Jump to navigation Jump to search
Documentation icon Template documentation[view · edit · history · purge ]

partial query to select all items with a unique value for a property.

Naming[edit]

Same convention of {{Multiple values}} : ?<itemname>_<property>_val1 for the default value of the statement

Usage[edit]

Items with a unique instance of (P31) value

{{sparql|query=
select ?item {
    {{unique values|instance of|?item}}
} limit 1000
}}
select ?item {  
     
     ?item wdt:P31  ?item_instance_of_val1
                        filter not exists { 
                          ?item wdt:P31  ?item_instance_of_val2
                        filter (?item_instance_of_val1 != ?item_instance_of_val2) .
                        }
 } limit 1000
Try it!

See also[edit]

Partial query that filters items that have a unique value for a property

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
property1 property

property for which we search unique values

Example
P31
Unknownoptional
item2

item variable or item id

Example
?item
Unknownoptional
    ?item wdt:  ?item_{{{1}}}_val1
                       filter not exists { 
                         ?item wdt:  ?item_{{{1}}}_val2
                       filter (?item_{{{1}}}_val1 != ?item_{{{1}}}_val2) .
                       }