Friday, February 24, 2012

Help With Making A Query

Hello,
With the following tables how would I create a query that would return all
rows from the Customers Table that have an entry in the Activity Table?
TableName: Customers
ID - Integer
CustomerID - VarChar
StartDate - Date
EndDate - Date
TableName: Activity
ID - Integer
CustomerID - VarChar
Extension - Bit
- Customer Table
ID CustomerID StartDate EndDate
1 Chuck1 9/1/06 9/30/06
2 Mike1 8/25/06 9/15/06
3 Dinah 8/23/06 9/1/06
4 James 7/11/06 8/30/06
- Activity Table
ID CustomerID Extension
1 Chuck1 1
3 James 0
The Query Should Return:
ID CustomerID StartDate EndDate
1 Chuck1 9/1/06 9/30/06
4 James 7/11/06 8/30/06
Thanks,
Chuckselect *
from Customers
inner join Activity on Activity.CustomerID =Customers.CustomerID

No comments:

Post a Comment