Hi everone, i have this query . only i want to exclude canceled dln1.quantity i put it in where clause ordr.canceled='n' and odln.canceled='n' it remove some record when i use it like this
((ORDR.Canceled='N') OR (ODLN.CANCELED='N')) this is not working . i want both of this canceled quantity to exclude.
SELECT
ORDR.DocNum, ORDR.DocDate, ORDR.CardCode, ORDR.CardName, OSLP.SlpName, ORDR.U_delterm, ORDR.U_U_MU,ORDR.U_DueDateStatus,
RDR1.ItemCode, RDR1.Dscription, RDR1.Quantity AS RDR1QTY, RDR1.Price, RDR1.Commission,ODLN.DocNum as DeliveryDocNum, ISNULL(DLN1.Quantity, 0) AS DLN1QTY,
ISNULL(RDN1.Quantity, 0) AS RDN1QTY, RDR1.U_ratelb, RDR1.U_freight, RDR1.U_toe, DLN1.QtyToShip, ORDR.DocEntry,
ORDR.DocStatus, RDR1.OpenQty, RDR1.DelivrdQty, ORDR.DocDueDate,ORDN.DocNum as ReturnDocNum,
ORIN.DocNum as ORINDocNum,isnull(RIN1.Quantity,0) as RIN1Qty,
isnull(RIN1.Quantity,0)+ISNULL(RDN1.Quantity, 0) as totalreturn
FROM ORDR Inner join RDR1 On ORDR .Docentry = RDR1 .Docentry
Inner join OSLP ON ORDR.SlpCode = OSLP.SlpCode
Left outer join DLN1 on DLN1.BaseLine = RDR1.LineNum AND DLN1.BaseEntry = RDR1.DocEntry and DLn1.Basetype = RDR1 .ObjType
left outer join ODLN on ODLN .Docentry = DLN1 .Docentry
Left outer join RDN1 on RDN1.BaseLine = DLN1.LineNum AND RDN1.BaseEntry = DLN1.DocEntry and RDN1.Basetype = DLn1 .ObjType
left outer join ORDN on ORDN.DocEntry = RDN1.DocEntrY
Left outer join inv1 on INV1.BaseLine = DLN1.LineNum AND INV1.BaseEntry = DLN1.DocEntry and INV1.Basetype = DLn1 .ObjType
left outer join oinv on OINV.DocEntry = INV1.DocEntrY
Left outer join RIN1 on RIN1.BaseLine = INV1.LineNum AND RIN1.BaseEntry = INV1.DocEntry and RIN1.Basetype = INV1 .ObjType
left outer join ORIN on ORIN.DocEntry = RIN1.DocEntrY
WHERE (ORDR.DocStatus = 'O') AND ORDR.DocDate Between '15.May.2013' and Convert(date,@ToDate) and ORDR.U_U_MU=@MillUnit AND ((ORDR.Canceled='N') OR (ODLN.CANCELED='N'))