<div dir="ltr">have you tried ->as_subselect_rs? That should be what you're looking for. Just make sure to define your "columns" on the subselect, or else it will try to get all the cols from the original table.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 27, 2021 at 1:22 PM Robert Rothenberg <<a href="mailto:robrwo@gmail.com">robrwo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have an aggregated query<br>
<br>
$rs->search_rs( undef, {<br>
columns => [<br>
"<a href="http://me.id" rel="noreferrer" target="_blank">me.id</a>",<br>
{ total => \ "SUM(me.val)" }<br>
],<br>
group_by => [ "<a href="http://me.id" rel="noreferrer" target="_blank">me.id</a>" ],<br>
} );<br>
<br>
<br>
I would like to join the results with another table, but that requires adding the columns to the group by clause.<br>
<br>
It's faster to do something like<br>
<br>
SELECT a.*, y.* from (select id, sum(val) from x group by id) a join y on <a href="http://a.id" rel="noreferrer" target="_blank">a.id</a>=y.x_id<br>
<br>
Is there a way in DBIC to do that, without creating a virtual result source?<br>
<br>
<br>
_______________________________________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" rel="noreferrer" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" rel="noreferrer" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" rel="noreferrer" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" rel="noreferrer" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a></blockquote></div>