Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non Related Tables

Status
Not open for further replies.

jaybird19

Programmer
Jan 16, 2009
7
US
Hi there, I have what I think is a simple question, but I do not know how to write the join statement.

I have two tables:
1) tbl_Customers with the following fields:
Customer_ID Customer_StartDate
123 3/1/2009
224 2/1/2009

2) tbl_Quarters with the following fields:
Quarter_ID Quarter_Months
Q0 0
Q1 3
Q2 6


I am trying to write a query with the following results:

Customer_ID Customer_StartDate Quarter Quarter_Date
123 3/1/2009 Q0 3/1/2009
123 3/1/2009 Q1 6/1/2009
123 3/1/2009 Q2 9/1/2009
224 2/1/2009 Q0 2/1/2009
224 2/1/2009 Q1 5/1/2009
224 2/1/2009 Q2 8/1/2009

I am not permitted to use a function. Also, the solution needs to be written in SQL - the query is much more complex than this and I am beyond using the query builder. I know how to use the dateadd function, I just can't figure out how to write my FROM clause.

Any help is greatly appreciated!!!
 
How about:

Code:
SELECT tbl_Customers.Customer_ID, tbl_Customers.Customer_StartDate, tbl_Quarters.Quarter_ID, DateAdd("m",[Quarter_Months],[Customer_StartDate]) AS Quarter_Date
FROM tbl_Customers, tbl_Quarters
ORDER BY tbl_Customers.Customer_ID, DateAdd("m",[Quarter_Months],[Customer_StartDate]);

 
I do not know how to write the join statement
As you want a cartesian product (aka cross join) you don't need any JOIN clause.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top