#
# example SPARQL query 119
#

@prefix schema: <https://schema.org/> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 
@prefix sh: <http://www.w3.org/ns/shacl#> . 
@prefix cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/> .


cello:Query_119 a sh:SPARQLExecutable ;
    sh:prefixes _:sparql_examples_prefixes ;
    rdfs:comment """Top 10 most represented dog breeds in Cellosaurus"""@en ; 
    schema:keywords "ox" , "species" , "breed" , "stats" ; 
    schema:target <https://sparql.cellosaurus.org/sparql> ; 
    sh:select """
PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
select ?species_ac ?species_name ?breed_ac ?breed_name (count(distinct(?cl)) as ?cl_count) where {
  values ?species_ac { "9615" } # Canis lupus familiaris (Dog)
  ?cl cello:derivedFromIndividualBelongingToSpecies ?species .
  ?species cello:isIdentifiedByXref / cello:accession ?species_ac .
  ?species cello:name ?species_name .
  optional {
    ?cl cello:derivedFromIndividualBelongingToBreed ?breed .
    ?breed cello:isIdentifiedByXref / cello:accession ?breed_ac .
    ?breed cello:name ?breed_name .
  }
}
group by ?species_ac ?species_name ?breed_ac ?breed_name
order by desc(count(distinct(?cl)))
limit 10
    """
    .

