How do I get rid of duplicate result form this Query Report Select 'tabStock Ledger Entry'


SELECT
`tabStock Ledger Entry`.`posting_date`,
`tabStock Ledger Entry`.`voucher_no` as "Delivery Note:Link/Delivery Note:90",
`tabStock Ledger Entry`.`item_code` as "Item Code:Link/Item:80",
`tabStock Ledger Entry`.`warehouse`,
`tabStock Ledger Entry`.`stock_uom`,

`tabPurchase Receipt`.`supplier_name` AS "Customer",
`tabStock Ledger Entry`.`actual_qty` AS "Delivered Quantity",
`tabStock Ledger Entry`.`incoming_rate`,
`tabBatch`.`batch_qty` AS "Balance Quantity",
`tabStock Ledger Entry`.`actual_qty`-`tabBatch`.`batch_qty` AS " Sold Quantity",

`tabStock Ledger Entry`.`incoming_rate` * `tabStock Ledger Entry`.`actual_qty` AS "Total Received",
`tabStock Ledger Entry`.`incoming_rate` * (`tabStock Ledger Entry`.`actual_qty`-`tabBatch`.`batch_qty`) AS "Total sold",
`tabStock Ledger Entry`.`incoming_rate` * `tabBatch`.`batch_qty` AS "Total Balance",
`tabDelivery Note Item`.`batch_no`,
`tabStock Ledger Entry`.`batch_no`,
`tabBatch`.`batch_id`

FROM
`tabStock Ledger Entry` INNER JOIN `tabPurchase Receipt` ON `tabStock Ledger Entry`.`voucher_no` = `tabPurchase Receipt`.`name`  INNER JOIN `tabBatch` ON `tabStock Ledger Entry`.`batch_no` = `tabBatch`.`Batch_id` INNER JOIN `tabDelivery Note Item` ON `tabStock Ledger Entry`.`batch_no` = `tabDelivery Note Item`.`Batch_no`
  

1 Like

it happend to me sometimes and the reason for it , its either wrong data or most important that the Relations are wrong or you need to fix them because wrong realtions or you maybe you forget table
its the reason that mysql make them duplicate

PS :
i suggest that you use frappe insights to make sure that your relations are fine