query-98a575e88409d142fbf3055828be95c7
Cavernia(P279)subclass of
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?songbook ?name (COUNT(DISTINCT ?song) AS ?songs)
(COUNT(DISTINCT ?male) AS ?male_lyricist) (COUNT(DISTINCT ?female) AS ?female_lyricist)
WHERE
{
{ ?song wdt:P31 wd:Q7366. }
UNION
{ ?song wdt:P31 wd:Q856713. }
?song wdt:P1433 ?songbook.
OPTIONAL
{
?song wdt:P676 ?lyricist.
?lyricist wdt:P21 ?gender.
BIND (IF (?gender = wd:Q6581097, ?song, 1/0) AS ?male)
BIND (IF (?gender = wd:Q6581072, ?song, 1/0) AS ?female)
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?songbook rdfs:label ?name.
}
}
GROUP BY ?songbook ?name
ORDER BY DESC (?songs)
LIMIT 100
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?female"):::projected
v10("?female_lyricist")
v5("?gender")
v4("?lyricist")
v6("?male"):::projected
v9("?male_lyricist")
v8("?name"):::projected
v2("?song"):::projected
v3("?songbook"):::projected
v9("?songs")
c2(["wd:Q7366"]):::iri
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c3(["wd:Q856713"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"wdt:P31"--> c2
end
union0r <== or ==> union0l
end
v2 --"wdt:P1433"--> v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P676".-> v4
v4 --"wdt:P21"--> v5
bind0[/"if(?gender = 'wd:Q6581097',?song,'1^^xsd:integer' / '0^^xsd:integer')"/]
v5 --o bind0
v2 --o bind0
bind0 --as--o v6
bind1[/"if(?gender = 'wd:Q6581072',?song,'1^^xsd:integer' / '0^^xsd:integer')"/]
v5 --o bind1
v2 --o bind1
bind1 --as--o v7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
v3 --"rdfs:label"--> v8
end
bind5[/"count(?song)"/]
v2 --o bind5
bind5 --as--o v9
bind6[/"count(?male)"/]
v6 --o bind6
bind6 --as--o v9
bind7[/"count(?female)"/]
v7 --o bind7
bind7 --as--o v10