Kurt Hansen wrote:
>> moving on to the next bug...
>>
>> Now, I'm having problems with the
>>
>> $args{'select'} = "$args{'group_by'}, AVG(prices) ";
>>
>> line. The sql that is being produced is:
>>
>> SELECT t2.type, t1.AVG{prices) ....
>>
>> so throws an error. The sql should be:
>>
>> SELECT t2.type, AVG(t1.prices) ....
>>
>> I've been looking through the docs trying to figure out how to properly 
>> specify AVG(COLUMN) in the 'select' argument with no success. Is it 
>> possible?
> 
> It just occurred to me that I could just to a regex on the sql statement 
> and fix the SELECT portion. I'm going to try that out.

Again replying to my own message in case others run into this issue.

The regex worked. However, I found at better way -- alias the group 
function, e.g.

$args{'select'} = "$args{'group_by'}, AVG(prices) as avg";

This produces a sql statement like:

SELECT t2.type, AVG(prices) as avg ...

An added benefit is that the resulting list of hashes has 'avg' as a key 
in the hashes rather than AVG(t1.prices).

Take care,

Kurt

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to