in reply to Re^3: Get top N rows in each group with DBIx::Class
in thread Get top N rows in each group with DBIx::Class

Hm, that sounds like a good idea, to assign intra-group row numbers to all records first, then constrain in all other ways, then constrain to N per group, knowing that the row numbers may not be sequential but will be ordered. Thanks, I'll try it!


The way forward always starts with a minimal test.
  • Comment on Re^4: Get top N rows in each group with DBIx::Class

Replies are listed 'Best First'.
Re^5: Get top N rows in each group with DBIx::Class
by chacham (Prior) on Nov 27, 2017 at 13:31 UTC

    Let us know if it works!

    BTW, this is a tactic easily used with CTEs, where each CTE is like another step. With good naming (long table names) is can be self-explanatory too.

    If you cannot use CTEs, just nest sub-tables. Same difference, though not as clear due to formatting.