Query

            PREFIX awm:<http://muse.aucklandmuseum.com/databases/cenotaph#>

            SELECT *
            WHERE
            {
               {
                  SELECT ?namePosition (COUNT(?namePosition) AS ?numberDied)
                  WHERE {
                    ?person awm:diedAt_country ?diedAt .
                    ?diedAt awm:addressConstitutedOf ?addressConstitutedOf .
                    ?addressConstitutedOf awm:namePosition ?namePosition .
                  }
                  GROUP BY ?namePosition
                  HAVING (COUNT(?namePosition) > 3)
                  ORDER BY DESC(?numberDied) ?namePosition
               }
            UNION
               {
                  SELECT ?namePosition (COUNT(?numberDied) as ?numberDied)
                  WHERE
                  {
                     SELECT ?namePosition (COUNT(?namePosition) AS ?numberDied)
                     WHERE {
                       ?person awm:diedAt_country ?diedAt .
                       ?diedAt awm:addressConstitutedOf ?addressConstitutedOf .
                       ?addressConstitutedOf awm:namePosition ?nameOfPosition .
                       BIND ( "Other" AS ?namePosition)
                     }
                     GROUP BY ?nameOfPosition ?namePosition
                     HAVING (COUNT(?namePosition) <= 3)
                     ORDER BY DESC(?numberDied) ?namePosition
                  }
                  GROUP BY ?namePosition
               }
            }

Results

      

Home