I&#39;m trying to code a simple query in DBIC. I get an error, <br>and don&#39;t understand why. What am I doing wrong?<br><br>QUERY:<br>SELECT sym as stc, count(*) as stc_count<br>FROM i1tickets<br>GROUP BY stc <br>ORDER BY stc_count DESC;<br>
<br>CODE:<br>$i1_tic_rs <br>  = $schema_pg-&gt;resultset(&#39;I1tickets&#39;)-&gt;search(<br>  {},<br>  {<br>    select =&gt; [<br>      &#39;sym&#39;,<br>      { count =&gt; &#39;*&#39; },<br>    ],<br>    as =&gt; [qw/<br>
      stc<br>      stc_count<br>    /],<br>    group_by =&gt; [qw/ stc /],<br>    order_by =&gt; { -desc =&gt; [qw/ stc_count /] },<br>  }<br>);<br><br>ROW:<br>while ( $row = $i1_tic_rs-&gt;next ) {<br>  $stc            = $row-&gt;stc;<br>
  $stc_count = $row-&gt;stc_count;<br>  ....<br><br>ERROR:<br>DBIx::Class::ResultSet::next(): DBI Exception: DBD::Pg::st execute failed: ERROR:  column &quot;stc_count&quot; does not exist<br>LINE 1: ...OUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count ...<br>
                                                             ^ [for Statement &quot;SELECT sym, COUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count DESC&quot;]<br><br>I don&#39;t see the alias declarations in the error msg...<br>
<br>BTW, is there a DBIC helper tool you can feed an sql<br>
query and have it spit out Perl code? I could use one ;-)<br><br>Thanks!<br>