I'm trying to code a simple query in DBIC. I get an error, <br>and don'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->resultset('I1tickets')->search(<br> {},<br> {<br> select => [<br> 'sym',<br> { count => '*' },<br> ],<br> as => [qw/<br>
stc<br> stc_count<br> /],<br> group_by => [qw/ stc /],<br> order_by => { -desc => [qw/ stc_count /] },<br> }<br>);<br><br>ROW:<br>while ( $row = $i1_tic_rs->next ) {<br> $stc = $row->stc;<br>
$stc_count = $row->stc_count;<br> ....<br><br>ERROR:<br>DBIx::Class::ResultSet::next(): DBI Exception: DBD::Pg::st execute failed: ERROR: column "stc_count" does not exist<br>LINE 1: ...OUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count ...<br>
^ [for Statement "SELECT sym, COUNT( * ) FROM i1tickets me GROUP BY stc ORDER BY stc_count DESC"]<br><br>I don'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>