Having condition for fields using functions supported?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Having condition for fields using functions supported?

Christian Carlow-OFBizzer
Is there anyway to implement a having condition for a field using a
function?  Such as below using SUM function?:

SELECT
     te.time_entry_id, te.quantity_produced, sum(te2.quantity_produced)
FROM
     time_entry te left outer join
     time_entry_assoc tea on te.time_entry_id = tea.time_entry_id_to
left outer join
     time_entry te2 on tea.time_entry_id = te2.time_entry_id
GROUP BY
      te.time_entry_id
HAVING
     te.quantity_produced = sum(te2.quantity_produced)
Reply | Threaded
Open this post in threaded view
|

Re: Having condition for fields using functions supported?

Jacques Le Roux
Administrator
At least the HAVING word exists in OFBiz even if it's not used in OOTB code
I found this warning though
//FIXME: handling HAVING, don't need ORDER BY for nested views

In all cases you can always switch to plain SQL if you can't make it work

Jacques

Le 16/09/2014 16:48, Christian Carlow a écrit :

> Is there anyway to implement a having condition for a field using a function?  Such as below using SUM function?:
>
> SELECT
>     te.time_entry_id, te.quantity_produced, sum(te2.quantity_produced)
> FROM
>     time_entry te left outer join
>     time_entry_assoc tea on te.time_entry_id = tea.time_entry_id_to left outer join
>     time_entry te2 on tea.time_entry_id = te2.time_entry_id
> GROUP BY
>      te.time_entry_id
> HAVING
>     te.quantity_produced = sum(te2.quantity_produced)
>