IN Linux Distinct SQL is not working with UNNEST

别等时光非礼了梦想. 提交于 2019-12-02 11:16:47

If getting duplicate rows is the problem, try this

 SELECT billing_billmanagement.creation_date,
           billing_billmanagement.bill_number,
           inventory_product.product_name AS product,
           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)
    WHERE billing_billmanagement.creation_date BETWEEN '2017-12-04' AND '2017-12-06'
    GROUP BY 1,
             2,
             3,
             4
    ORDER BY 1 ASC;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!