Logo of Wikidata

Welcome to Wikidata, Jona!

Wikidata is a free knowledge base that you can edit! It can be read and edited by humans and machines alike and you can go to any item page now and add to this ever-growing database!

Need some help getting started? Here are some pages you can familiarize yourself with:

  • Introduction – An introduction to the project.
  • Wikidata tours – Interactive tutorials to show you how Wikidata works.
  • Community portal – The portal for community members.
  • User options – including the 'Babel' extension, to set your language preferences.
  • Contents – The main help page for editing and using the site.
  • Project chat – Discussions about the project.
  • Tools – A collection of user-developed tools to allow for easier completion of some tasks.

Please remember to sign your messages on talk pages by typing four tildes (~~~~); this will automatically insert your username and the date.

If you have any questions, don't hesitate to ask on Project chat. If you want to try out editing, you can use the sandbox to try. Once again, welcome, and I hope you quickly feel comfortable here, and become an active editor for Wikidata.

Best regards! Liuxinyu970226 (talk) 00:10, 14 May 2015 (UTC)Reply

Request a query edit

Shame - I had answers for you. Fancy putting it back - your second query is a very good example of an issue quite a lot of people will have. --Tagishsimon (talk) 21:48, 19 December 2018 (UTC)Reply

@Tagishsimon: I think that I found it :
SELECT ?item ?itemLabel ?party ?partyLabel ?partycount where
{ {SELECT ?item (count(?party) as ?partycount) WHERE {
  ?item p:P39 ?statement.
  ?statement ps:P39 wd:Q17781726.
  ?statement pq:P2937 wd:Q30544772 .
  ?item wdt:P102 ?party.
  MINUS { ?statement pq:P4100 ?group } .
}
 group by ?item } .
 ?item wdt:P102 ?party .
 FILTER (?partycount=1)
 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }

 }
Try it!

We can restore the subject for reference if you want ! ;) Jona (talk) 21:53, 19 December 2018 (UTC)Reply

No, we're good. Someone else will dial in the problem sometime. I will remind you of having (?partycount=1) which is an alternative to your filter; and do much what you've just done above, but with a named subquery rather than a nested query.
SELECT ?item ?itemLabel ?partyLabel  with {
  select DISTINCT ?item (count(?party) as ?partycount) WHERE {
  ?item p:P39 ?statement.
  ?statement ps:P39 wd:Q17781726.
  ?statement pq:P2937 wd:Q30544772 .
  ?item wdt:P102 ?party.
  MINUS { ?statement pq:P4100 ?group } .
} group by ?item having (?partycount=1) } as %items
where
{
  include %items
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
}
Try it!
--Tagishsimon (talk) 21:57, 19 December 2018 (UTC)Reply