> Hi, in my app i have orders model/table and i would like to retrieve
> average order cost (SELECT AVG(cost) FROM orders;), how can i get this
> done in Play?
This looks like a standard JPA query
Order.find("select avg(o.cost) from Order o").fetch()
Should do what you need.
Regards, Alexander
Regards,
Philippe
> But what type of variable should the results be assigned to?
java.lang.Number for example
SELECT AVG(cost) as average, MAX(cost) as maximum, MIN(cost) as
minimum FROM orders;
If you are using raw SQL, that should work and give you average,
maximum, and minimum in the resulting row.
Thanks, Chris
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>