<font size=2 face="sans-serif">I have gone through all that, tried a bunch
of different ways of going at it and still can't get the results I need.
If these docs had actual explanations of what it is doing and why and how
I would have a much better time of it. There are so many huge areas where
they just drop code on the page and walk away expecting that you already
understand what they were thinking when they wrote it. While the correlated
subqueries section seems to be on the right track, the example doesn't
do what I need and there is no real expansion of the idea/methodology.
It amazes me that nobody has ever needed a total of rows in one table based
on a key from another table. It is very simple in raw sql, but I cannot
even get that to work in DBIx::Class. </font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">From:</font>
<td><font size=1 face="sans-serif">&quot;Daniel J. Luke&quot; &lt;dluke@geeklair.net&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font>
<td><font size=1 face="sans-serif">&quot;DBIx::Class user and developer
list&quot; &lt;dbix-class@lists.scsys.co.uk&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font>
<td><font size=1 face="sans-serif">05/14/2012 02:14 PM</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font>
<td><font size=1 face="sans-serif">Re: [Dbix-class] Query problem</font></table>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>On May 14, 2012, at 2:21 PM, Kenneth S Mclane wrote:<br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; my $rs = $c-&gt;model('ORANGES::Account')-&gt;search_rs(undef,
{ <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; join =&gt;
{ servers =&gt; 'subs' }, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select =&gt;
[ &nbsp;{ count =&gt; 'subsystem_id' } ], <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; as =&gt; [
qw/ num_subs / ], <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group_by =&gt;
[ qw/ account_code subs.server_id server_name server_type os_name &nbsp;
/ ], <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows =&gt;
15, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page =&gt;
$page, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; order_by =&gt;
['account_code', 'server_name'], <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; }); <br>
&gt; <br>
&gt; But the SQL looks like it is getting closer to what I need: <br>
&gt; <br>
&gt; SELECT <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.server_id, &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a.account_code, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.server_name, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.server_type, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s.os_name, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(select count(*) from
server ss, subsserystem sb <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
where ss.server_id = sb.server_id <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
and ss.server_id = s.server_id) as num_subsystems &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;account a, <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;server s <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and a.account_id = s.account_id
<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; order by a.account_code,
s.server_name&quot; <br>
&gt; <br>
&gt; I have exhausted all the docs I can find<br>
<br>
Does this help?<br>
<br>
</font></tt><a href="http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Subqueries"><tt><font size=2>http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Subqueries</font></tt></a><tt><font size=2><br>
<br>
I also found reading through the actual DBIx::Class (and SQL::Abstract)
code illuminating when first looking at using DBIx::Class for some stuff.<br>
<br>
&gt; and if I can't get this count of subsystems relater to servers to
work I will have to dump this as a feasible development platform.<br>
<br>
you know you can use strait SQL with DBIx::Class too if you need to (although
it's better if you don't):<br>
<br>
</font></tt><a href="http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Arbitrary_SQL_through_a_custom_ResultSource"><tt><font size=2>http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Arbitrary_SQL_through_a_custom_ResultSource</font></tt></a><tt><font size=2><br>
<br>
&gt; I'm really hoping someone can come up with a concrete answer to do
this. This is one of those things never addressed directly in any of the
docs. If I had a example to work with I could figure it out, but I'm flying
blind here.<br>
<br>
There's not always an easy example that just shows you what you need to
do - sometimes you have to understand how things work instead of just copy+paste+modify...<br>
<br>
--<br>
Daniel J. Luke &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; <br>
+========================================================+ &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
| *---------------- dluke@geeklair.net ----------------* | &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
| *-------------- </font></tt><a href=http://www.geeklair.net/><tt><font size=2>http://www.geeklair.net</font></tt></a><tt><font size=2>
-------------* | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
+========================================================+ &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
| &nbsp; Opinions expressed are mine and do not necessarily &nbsp; | &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;<br>
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reflect the opinions of my employer.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
+========================================================+<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
List: </font></tt><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class"><tt><font size=2>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</font></tt></a><tt><font size=2><br>
IRC: irc.perl.org#dbix-class<br>
SVN: </font></tt><a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/"><tt><font size=2>http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</font></tt></a><tt><font size=2><br>
Searchable Archive: </font></tt><a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk"><tt><font size=2>http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</font></tt></a><tt><font size=2><br>
<br>
</font></tt>
<br>
<br>