You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Christian Carlow <ch...@gmail.com> on 2014/09/16 16:48:07 UTC

Having condition for fields using functions supported?

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)

Re: Having condition for fields using functions supported?

Posted by Jacques Le Roux <ja...@les7arts.com>.
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)
>