1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
SELECT dbo.SorMaster.Customer + ' ' + dbo.ArCustomer.Name AS Customer, dbo.SorDetail.MPrice * dbo.SorDetail.MBackOrderQty / dbo.TblCurrency.SellExchangeRate AS Order_Value, dbo.SorDetail.MLineShipDate, dbo.SorDetail.SalesOrder, dbo.SorDetail.SalesOrderLine, ISNULL(dbo.SorCancelled.SalesOrder, 'OK') AS ORDOK, dbo.SorCancelled.SalesOrderLine AS EXPR2, dbo.TblCurrency.SellExchangeRate FROM dbo.SorDetail INNER JOIN dbo.SorMaster ON dbo.SorDetail.SalesOrder = dbo.SorMaster.SalesOrder INNER JOIN dbo.ArCustomer ON dbo.SorMaster.Customer = dbo.ArCustomer.Customer INNER JOIN dbo.TblCurrency ON dbo.SorMaster.Currency = dbo.TblCurrency.Currency LEFT OUTER JOIN dbo.SorCancelled ON dbo.SorDetail.SalesOrder = dbo.SorCancelled.SalesOrder AND dbo.SorDetail.SalesOrderLine = dbo.SorCancelled.SalesOrderLine WHERE (dbo.SorDetail.MLineShipDate >= CONVERT(DATETIME, '2010-01-01 00:00:00', 102)) AND (dbo.SorDetail.MLineShipDate <= CONVERT(DATETIME, '2010-02-01 00:00:00', 102)) GROUP BY dbo.SorDetail.MPrice * dbo.SorDetail.MBackOrderQty / dbo.TblCurrency.SellExchangeRate, dbo.SorMaster.OrderStatus, dbo.SorMaster.Customer + ' ' + dbo.ArCustomer.Name, dbo.SorDetail.MLineShipDate, dbo.SorDetail.SalesOrderLine, dbo.SorDetail.SalesOrder, dbo.SorDetail.MBackOrderQty, dbo.SorDetail.SalesOrder, dbo.ArCustomer.Customer, dbo.SorCancelled.SalesOrder, dbo.SorCancelled.SalesOrderLine, dbo.TblCurrency.SellExchangeRate HAVING (dbo.SorMaster.OrderStatus <> '9') AND (ISNULL(dbo.SorCancelled.SalesOrder, 'OK') = 'OK') AND (dbo.SorDetail.MPrice * dbo.SorDetail.MBackOrderQty / dbo.TblCurrency.SellExchangeRate > 0) ORDER BY Sor.Master.Customer