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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to join 4 tables and select a calculated field

Status
Not open for further replies.

GarHeard

Programmer
May 3, 2005
28
US
How would you write the following query ?

I have a table of Customers AS C with a CustomerNumber (Primary Key) , State , DateA.

I have a table of Products AS P with a CustomerNumber (Foreign Key) and Property Type.

I have a table of StateCodes AS S with a State.

I have a table of StateDormancy as D with a State and PropertyDateB.

I want to select records from the Customer table (foreign customers) that do not have a matching value in the StateCodes table (S) -->>C.State NOT IN (S.State).

I also want to select a calculated date, DateX which equals C.DateA minus D.PropertyDateB where D.State = 'DE'

Thus, I want to SELECT C.CustomerNumber, C.State, DateX (a calculated field)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top