<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=3>hi,Matija Grabnar : </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=4> I have met the same problem with you when I use
DBIC to order by a column which doesn't exist.As Mr </FONT><FONT size=3>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.</FONT></DIV>
<DIV> The tip is that you can use "order by (num)" in
MySQL,for instance:</DIV>
<DIV><FONT size=4>"SELECT stu_id,SUM(score) FROM stu_score group by stu_id order
by 2 desc"</FONT></DIV>
<DIV><FONT size=4>It does work~~</FONT></DIV>
<DIV><FONT size=4>So you can use DBIC like this:</FONT></DIV>
<DIV><FONT size=4> my $st =
$schema->resultset('StuScore')->search(<BR> {},<BR> {<BR> select
=> ['stu_id',{ sum => 'score'
}],<BR> as =>
['stu','total_score'],<BR> group_by =>
['stu_id'],<BR> order_by => ['2
desc'],<BR> }<BR> );</FONT></DIV>
<DIV><FONT size=4>Remember,it works in MySQL only.(or in other words,I don't
know if it could work in other DB servers).</FONT></DIV>
<DIV><FONT size=4>Enjoy it^^</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> </DIV></FONT>
<DIV><FONT size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT size=2>���壬Touya<BR>Adways Co.Ltd <BR>Telephone:
(86-21)63410128-212<BR>FAX: (86-21)63410208<BR>Email: <A
href="mailto:dong.yi@adways.net">dong.yi@adways.net</A><BR><A
href="http://dev.adways.net">http://dev.adways.net</A></FONT></DIV></BODY></HTML>