开发者

Aggregate function on composite user type

开发者 https://www.devze.com 2023-03-17 08:23 出处:网络
I have a composite user type that represents a monetary amount. This type spans to two columns. -Amount

I have a composite user type that represents a monetary amount. This type spans to two columns.

-Amount
-Currency

When i am creating an HQL query that performs an aggregate function like "avg" on a property using this composite user type an exception is thrown. The reason as it seems is that AvgFunction cannot operate with types that have multiple columns.

Is there any way to use 开发者_Python百科CompositeUserType in aggregate functions?

Thanks in advance and best regards

Stathis Alexopoulos


Your query doesn't make much sense. What would be the average of these three rows?

amount    currency
5         USD
10        EUR
15        YEN

You may average the amounts and neglect the currency:

select avg(bill.fullAmount.amount) from BillBean as bill

but you can't average the monetary amounts (i.e. the tuple [amount, currency]).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号