[Dbix-class] What's the best way to join with an aggregated query in DBIC

Robert Rothenberg robrwo at gmail.com
Wed Jan 27 11:19:57 GMT 2021


I have an aggregated query

   $rs->search_rs( undef, {
     columns => [
       "me.id",
       { total => \ "SUM(me.val)" }
     ],
     group_by => [ "me.id" ],
   } );

     
I would like to join the results with another table, but that requires adding the columns to the group by clause.

It's faster to do something like

    SELECT a.*, y.* from (select id, sum(val) from x group by id) a join y on a.id=y.x_id

Is there a way in DBIC to do that, without creating a virtual result source?




More information about the DBIx-Class mailing list