Hi,
I have a query to show all orders and its units that is still "Pending". Here is the query:
The problem that I am having is I want to add more condition on the query, to not displaying/resulting some certain records based on its OrderID and UnitID. If I modify the HAVING clause to:
it will show all records except OrderID 494 and UnitID 5. What I want is to not display one record which has orderID 494 and unitID 5 (orderID 494 has unitID 5 and 11). I hope you understand my query. Anyone can help? THanks!
I have a query to show all orders and its units that is still "Pending". Here is the query:
Code:
SELECT TblCustOrderUnit.OrderID, TblCustomer.CustomerName, TblCustOrder.PONumber, TblCustOrder.JobName, TblCustOrder.CustomerUDD, TblUnits.UnitName, Count(TblCustOrderUnit.UnitID) AS Qty, TblCustOrderUnit.Status
FROM TblUnits INNER JOIN ((TblCustomer INNER JOIN TblCustOrder ON TblCustomer.[CustomerID] = TblCustOrder.[CustomerID]) INNER JOIN TblCustOrderUnit ON TblCustOrder.[CustOrderID] = TblCustOrderUnit.[OrderID]) ON TblUnits.[UnitID] = TblCustOrderUnit.[UnitID]
GROUP BY TblCustOrderUnit.OrderID, TblCustomer.CustomerName, TblCustOrder.PONumber, TblCustOrder.JobName, TblCustOrder.CustomerUDD, TblUnits.UnitName, TblCustOrderUnit.Status, TblCustomer.CustomerName, TblCustOrder.DeliveryStatus, TblCustOrderUnit.PartOrdered
HAVING (((TblCustOrderUnit.Status)="Pending") AND ((TblCustOrder.DeliveryStatus)="Pending") AND ((TblCustOrderUnit.PartOrdered)=False))
ORDER BY TblCustOrder.CustomerUDD, TblCustomer.CustomerName;
The problem that I am having is I want to add more condition on the query, to not displaying/resulting some certain records based on its OrderID and UnitID. If I modify the HAVING clause to:
Code:
HAVING ([COLOR=#F57900]((TblCustOrderUnit.OrderID)<>494) AND ((TblCustOrderUnit.UnitID)<>5)[/color] AND (TblCustOrderUnit.Status)='Pending') AND ((TblCustOrder.DeliveryStatus)='Pending') AND ((TblCustOrderUnit.PartOrdered)=False)
it will show all records except OrderID 494 and UnitID 5. What I want is to not display one record which has orderID 494 and unitID 5 (orderID 494 has unitID 5 and 11). I hope you understand my query. Anyone can help? THanks!