From: Qaspec on
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
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
>