Limit and sort per level?

Thank you.

Hmm, I wonder if I can make this generic enough to work for any combination of classes and properties without having to predefine Stored Queries?

It also needs to tap into the language fallback functionality:

So a complete, more generic example would be:

  1. The class :Country has properties :name, :headOfState.

  2. The class :Person has properties :name, :birthDate

  3. We can determine a priori that :name is an rdf:langString and want to use that information to apply a fallback.

  4. We want to get the top 5 Countries ranked by population and we want to get 3 Heads of State ranked by birthDate.

So basically:

?country a :Country;
   :population ?population .
   :name ?name . // Apply Fallback

   ORDER BY ?population
   LIMIT 5

// Correlated Query:

?country  :headOfState ?Person;
   :birthDate ?birthDate .
   :name ?name . // Apply Fallback

   ORDER BY ?birthDate
   LIMIT 3

Can this be achieved? I.e. how customizable is the SQS? Can it accept entire graph patterns?
(We have 1000s of variations on this theme so a generic solution is important :sweat_smile:)

Thanks!