It is not quite clear what you are trying to do. Can you provide a smalltest table to show what you want to achieve?
Cheers,Greg
--Crunchy Data - https://www.crunchydata.comEnterprise Postgres Software Products & Tech Support