User:TweetsFactsAndQueries/Queries/gender distribution in art subjects

Originally posted on Twitter and on Mastodon. on Mastodon].

# number of depicted subjects by gender
# uncomment the last part of line 7 to limit the query to human subjects,
# and change ?depicted to DISTINCT ?depicted in line 5 to only count each subject once regardless of how many works depict them
SELECT ?gender ?genderLabel ?count WITH {
  SELECT ?gender (COUNT(?depicted) AS ?count) WHERE {
    ?work wdt:P180 ?depicted.
    ?depicted # wdt:P31 wd:Q5;
              wdt:P21 ?gender.
  }
  GROUP BY ?gender
} AS %results WHERE {
  INCLUDE %results.
  FILTER(!wikibase:isSomeValue(?gender))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)
# (note that this query doesn’t group any genders together automatically, but when using this data,
# you should probably do so manually – e. g. include transgender <gender> in the numbers for <gender>, in accordance with their “subclass of” statements)
Try it!