c# - Why is my SQL query returning duplicate results? -
the sql below - each result coming 3 times rather once.
select consignments.legacyid, tripdate, collectionname, deliveryname, pallets, weight, baserate, consignments.fuelsurcharge, additionalcharges, baserate * quantity 'invoicevalue', consignments.customer, invoicenumber, case when child.legacyid = consignments.customer child.legacyid when parent.legacyid = consignments.customer parent.legacyid else this.legacyid end 'invoiceacc' sageaccount left join sageaccount parent on parent.legacyid = this.invoiceaccount left join sageaccount child on this.legacyid = child.invoiceaccount join consignments on (consignments.customer = this.legacyid , this.customer = 'true') or (consignments.customer = parent.legacyid , parent.customer = 'true') or (consignments.customer = child.legacyid , child.customer = 'true') (this.legacyid = @customer) , (tripdate between @fromdate , @todate) , (invoicenumber not null)
the sql given me similar query, time have modified try use query i'm doing now, i'm assuming i'm doing stupid.
many thanks.
join consignments on (consignments.customer = this.legacyid , this.customer = 'true') or (consignments.customer = parent.legacyid , parent.customer = 'true') or (consignments.customer = child.legacyid , child.customer = 'true')
i guess u should use "this.invoiceaccount" instead of this.legacyid
Comments
Post a Comment