I have a database where I have have (correctly I think) normalised out my data, however now Im trying to create some queries which pull data from four different related tables and Im really struggling.
My database is built around a Plots table (tblPlots) which has the following fields
PlotID - Autonumber
Sector
Block
Plot
Status - Related to tblLookupStatus
ClientID - Related to tblClients
PaymentOverdue - Yes/No field
I also have a Clients table (tblClients) which has the following fields
ClientID - Autonumber
Name
Surname
Telephone
Address
Email
A Payments table (tblPayments) which has:
PaymentID - Autonumber
PlotID - Related to tblPlots
PaymentAmount
PaymentDate
A Lookup table (tblLookupStatus) which holds the Status descriptions and their corresponding RGB values
StatusID - Autonumber
StatusDescription
R
G
B
What Im trying to do is create a query which shows the following information:
Sector
Block
Plot
Status (description looked up from tblStatus)
Name - Concatinated Name and Surname fields from matching row in tblClients
Telephone
Email
Last Payment Date (MAX value from tblPagos for this Plot)
WHERE
Overdue = True
Ive tried using the query builder to create the inner joins I think I need, but if I specify my Where clause I get no results (Even thought I have set one row in the Plots table to overdue. If I omit my where clause I always get three rows back (of the same data).
Can anyone with some expert SQL knowledge show me what my SQL should look like to pull this information out in this format?
TIA
Jon
My database is built around a Plots table (tblPlots) which has the following fields
PlotID - Autonumber
Sector
Block
Plot
Status - Related to tblLookupStatus
ClientID - Related to tblClients
PaymentOverdue - Yes/No field
I also have a Clients table (tblClients) which has the following fields
ClientID - Autonumber
Name
Surname
Telephone
Address
A Payments table (tblPayments) which has:
PaymentID - Autonumber
PlotID - Related to tblPlots
PaymentAmount
PaymentDate
A Lookup table (tblLookupStatus) which holds the Status descriptions and their corresponding RGB values
StatusID - Autonumber
StatusDescription
R
G
B
What Im trying to do is create a query which shows the following information:
Sector
Block
Plot
Status (description looked up from tblStatus)
Name - Concatinated Name and Surname fields from matching row in tblClients
Telephone
Last Payment Date (MAX value from tblPagos for this Plot)
WHERE
Overdue = True
Ive tried using the query builder to create the inner joins I think I need, but if I specify my Where clause I get no results (Even thought I have set one row in the Plots table to overdue. If I omit my where clause I always get three rows back (of the same data).
Can anyone with some expert SQL knowledge show me what my SQL should look like to pull this information out in this format?
TIA
Jon