I am a newbie in ODI 12c. I have recently installed it and did some tests on it. I have a table like this:
My goal is that I want to group by on customer_id and make a JSON format string for each customer_id. In Oracle database, I can do that with this query as following below:
select customer_id,'[' || listagg('{"TRX_ID":'
|| '"' || trx_id || '"' || ',"count_rules":'
|| '"' || count_rules || '"'
|| '}',',') within group(order by count_rules) || ']' as JSON_RULES
from (select customer_id,trx_id,count(rules) as count_rules from test_rules group by
customer_id,trx_id) group by customer_id
The result is like this:
However, I want to do the same work in ODI 12c, would you please guide me how I can do that?
Any help is really appreciated.


The aggregate component in a mapping can be parametrized to use a custom GROUP BY clause if needed.
Here is how to use this component :
'[' || listagg('{"TRX_ID":' || '"' || trx_id || '"' || ',"count_rules":' || '"' || count_rules || '"' || '}',',') within group(order by count_rules) || ']'Is Group Byproperty of all attributes toAuto. Auto means that all attributes that DON'T have an aggregate function in their expression will be part of the GROUP BY clause. So in your case only CUSTOMER_ID should be in the GROUP BY clause and you should be fine. If the JSON_RULES attribute is mistakenly added in the GROUP BY clause, you can still set theIs Group Byproperty to No.[EDIT] I didn't see you had a subquery in there. You just need to put a first aggregate component before the one I showed to aggregate by CUSTOMER_ID and TRX_ID.