Reputation: 424
Here is my table. I have made the following query and get the result:
SELECT
GROUP_CONCAT(CONCAT('', j0.rent_agree_id,'-',j0.rent_sche_id) ) AS agreement_ref_no
FROM
rent_provision_history AS j0
GROUP BY provision_date
But I want to see the result differently.
For example for the last result row i am getting now: 4-68,4-69,6-107,6-108,6-109
But I want to see it like that: 4(68,69)|5(107,108,109)
How can i do that?
Upvotes: 1
Views: 64
Reputation: 1269443
You need two levels of aggregation:
SELECT provision_date,
GROUP_CONCAT(rent_agree_id, '(', rsi, ')' SEPARATOR '|') agreement_ref_no
FROM (SELECT j0.rent_agree_id, GROUP_CONCAT(j0.rent_sche_id) as rsi
FROM rent_provision_historyj0
GROUP BY j0.provision_date, j0.rent_agree_id
) j0
GROUP BY j0.provision_date;
Upvotes: 2