POSTGRESQL - функция UNNEST не работает в LINUX
Я получил дубликат строки. хотя я уже добавил "DISTINCT", когда я запускаю запрос дубликаты записей показывают.
id | product | service
---+-----------------------
1 |p1 |s1
2 |p2 |s2
3 |p2 |s2
SELECT DISTINCT billing_billmanagement.creation_date,
billing_billmanagement.bill_number,
unnest(array_agg(DISTINCT inventory_product.product_name)) AS product,
unnest(array_agg(DISTINCT services_service.name)) AS service
FROM billing_billmanagement
INNER JOIN users_staffuser ON (billing_billmanagement.staff_id = users_staffuser.id)
INNER JOIN auth_user ON (users_staffuser.user_id = auth_user.id)
LEFT OUTER JOIN billing_customerproductbill ON (billing_billmanagement.id = billing_customerproductbill.bill_id)
LEFT OUTER JOIN inventory_product ON (billing_customerproductbill.product_id = inventory_product.id)
LEFT OUTER JOIN billing_customerservicebill ON (billing_billmanagement.id = billing_customerservicebill.bill_id)
LEFT OUTER JOIN services_service ON (billing_customerservicebill.service_id = services_service.id)
LEFT OUTER JOIN billing_customer ON (billing_billmanagement.customer_id = billing_customer.id)
WHERE billing_billmanagement.creation_date BETWEEN '2017-11-01' AND '2017-12-02'
GROUP BY billing_billmanagement.creation_date,
billing_billmanagement.bill_number
ORDER BY billing_billmanagement.creation_date ASC
Что-то здесь не так?