hi,Matija Grabnar :
 
   I have met the same problem with you when I use DBIC to order by a column which doesn't exist.As Mr Matt S Trout said,"as" is only used by DBIC itself,but used to form the SQL.But I have a solution if you use MySQL as DB server.
    The tip is that you can use "order by (num)" in MySQL,for instance:
"SELECT stu_id,SUM(score) FROM stu_score group by stu_id order by 2 desc"
It does work~~
So you can use DBIC like this:
 my $st = $schema->resultset('StuScore')->search(
  {},
  {
   select   =>  ['stu_id',{ sum => 'score' }],
   as       =>  ['stu','total_score'],
   group_by =>  ['stu_id'],
   order_by =>  ['2 desc'],
  }
 );
Remember,it works in MySQL only.(or in other words,I don't know if it could work in other DB servers).
Enjoy it^^
 
 
 
 
董义,Touya
Adways Co.Ltd
Telephone: (86-21)63410128-212
FAX: (86-21)63410208
Email: [EMAIL PROTECTED]
http://dev.adways.net
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/

Reply via email to