Re: ways to use "Having"
Is this what you mean?
select
customer_id, name,
sum( if(date_of_operation='2016-1-1',amount,0) ) as jan1,
sum( if(date_of_operation between '2016-1-1' and '2016-1-31',amount,0) ) as restofjan,
from customers_logs
group by customer_id, name
having jan1>0 and restofjan>0;
Note that with `name` not aggregated in the Select list, it needs to be in the Group By list unless your DDL enforces that all name values are unique to corrsponding id values.
Subject
Written By
Posted
February 16, 2016 11:27AM
Re: ways to use "Having"
February 16, 2016 01:25PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.