From: Qaspec on 2 Nov 2009 15:48 New to SQL and I need a list of the customer numbers in the 2nd query that match customer numbers from the first. SELECT dbo.tblOrder.CustomerNumber FROM dbo.tblOrder INNER JOIN dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID Where ShipmentDt Between '9/1/2007' and '12/25/2008' Group By dbo.tblOrder.CustomerNumber SELECT dbo.tblOrder.CustomerNumber FROM dbo.tblOrder INNER JOIN dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID Where ShipmentDt Between '12/25/2008' and '3/26/2009' Group By dbo.tblOrder.CustomerNumber
From: Tom Cooper on 2 Nov 2009 16:10 SELECT dbo.tblOrder.CustomerNumber FROM dbo.tblOrder INNER JOIN dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID Where ShipmentDt Between '9/1/2007' and '12/25/2008' Group By dbo.tblOrder.CustomerNumber INTERSECT SELECT dbo.tblOrder.CustomerNumber FROM dbo.tblOrder INNER JOIN dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID Where ShipmentDt Between '12/25/2008' and '3/26/2009' Group By dbo.tblOrder.CustomerNumber; Tom "Qaspec" <Qaspec(a)discussions.microsoft.com> wrote in message news:26DE5CD5-37CA-4A4F-89E5-9C915A7F1EE9(a)microsoft.com... > New to SQL and I need a list of the customer numbers in the 2nd query that > match customer numbers from the first. > > > > > > SELECT dbo.tblOrder.CustomerNumber > > FROM dbo.tblOrder INNER JOIN > > dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID > > Where ShipmentDt Between '9/1/2007' and '12/25/2008' > > Group By dbo.tblOrder.CustomerNumber > > > > > > > > > > SELECT dbo.tblOrder.CustomerNumber > > FROM dbo.tblOrder INNER JOIN > > dbo.tblShipment ON dbo.tblOrder.OrderID = dbo.tblShipment.OrderID > > Where ShipmentDt Between '12/25/2008' and '3/26/2009' > > Group By dbo.tblOrder.CustomerNumber >
|
Pages: 1 Prev: rebulid master db Next: SQL Server 2008 SP1 Installation Problems |