Oups, my bad, very bad actually. I had in mind you had the same speed Mhz You can always run a raw SQL query, there're a lot in the CapacityDao due to the limitation on the mix of functions + group by.
On Wed, Jan 10, 2018 at 1:45 PM, Ivan Kudryavtsev <kudryavtsev...@bw-sw.com> wrote: > Hmmm, I don't think the math works that way, multiplication and sum are not > same order operations. Right now the only way I found is to fetch all rows > with required fields from db and do computation in the code, but it doesn't > look efficient though. > > 10 янв. 2018 г. 19:41 пользователь "Marc-Aurèle Brothier" < > ma...@exoscale.ch> > написал: > > Hmm, yeah that's what I realized after sending the email. With the DAO, you > can only apply function on a single column / entity attribute, therefore it > won't be possible as you want. Another way to achieve this would be to do > SELECT SUM(A), SUM(B) FROM T with the DAO, and on the Java side do the > multiplication. Woud that work for your use-case? > > > On Wed, Jan 10, 2018 at 1:27 PM, Ivan Kudryavtsev < > kudryavtsev...@bw-sw.com> > wrote: > > > Hello, Marc-Aurele, thank you for the snippet, but it looks like the sum > > usage everywhere in the codebase. It's aggregation over single field. > What > > I need is to pass multuplication of two fields (cores x speed) inside the > > sum, but I don't understand how to do it with dao... Thank you. > > > > 10 янв. 2018 г. 19:12 пользователь "Marc-Aurèle Brothier" < > > ma...@exoscale.ch> > > написал: > > > > > Have a look here: > > > https://github.com/apache/cloudstack/blob/master/engine/ > > > schema/src/com/cloud/storage/dao/VolumeDaoImpl.java#L347 > > > > > > Or you can search other example in the code base with this string > > > "Func.SUM": thttps:// > > > github.com/apache/cloudstack/blob/master/engine/schema/src/ > > > com/cloud/storage/dao/VolumeDaoImpl.java#L347 > > > > > > On Wed, Jan 10, 2018 at 9:42 AM, Ivan Kudryavtsev < > > > kudryavtsev...@bw-sw.com> > > > wrote: > > > > > > > Hello, colleagues, please could anyone guide me how to implement > > > > aggregation SUM over two fields multiplication? Many thanks in > advance. > > > > > > > > I'm trying to achieve: > > > > SELECT SUM(A * B) FROM T with DAO > > > > > > > > > > > > > > > > -- > > > > With best regards, Ivan Kudryavtsev > > > > Bitworks Software, Ltd. > > > > Cell: +7-923-414-1515 > > > > WWW: http://bitworks.software/ <http://bw-sw.com/> > > > > > > > > > >