C
conradtruscott
Hi,
I have two tables, one is Customers and the other is tblOrderFormsSent
which are linked via a one to many relationship. What I need to do is
get the most recent record of the date field for order forms sent and
then see if it is between certain values.
I'm trying to use the maketable query below however I get a 'you cannot
use an aggregate function in a WHERE clause'. I know I somehow need to
nest another SELECT statement in there but I'm not to sure where.
Could someone please help or point me to a good site on contructing SQL
statements?
I'm a beginner at all this! Thanks in advance!
SELECT Customers.[Customer Number], Customers.[Business Name],
Customers.AddressState, Customers.[Street Address 1], Customers.[Street
Address 2], Customers.City, Customers.Postcode, Customers.SendOrderForm
INTO CustomerstoprintNT
FROM Customers INNER JOIN tblOrderFormsSent ON Customers.[Customer
Number] = tblOrderFormsSent.[Customer Number]
WHERE (((Customers.AddressState)="NT") AND
((Customers.SendOrderForm)=Yes) AND
((tblOrderFormsSent.OrderFormsSent)=Max(([tblOrderFormsSent].[OrderFormsSent])
Between Date()-21 And Date()-10000)));
I have two tables, one is Customers and the other is tblOrderFormsSent
which are linked via a one to many relationship. What I need to do is
get the most recent record of the date field for order forms sent and
then see if it is between certain values.
I'm trying to use the maketable query below however I get a 'you cannot
use an aggregate function in a WHERE clause'. I know I somehow need to
nest another SELECT statement in there but I'm not to sure where.
Could someone please help or point me to a good site on contructing SQL
statements?
I'm a beginner at all this! Thanks in advance!
SELECT Customers.[Customer Number], Customers.[Business Name],
Customers.AddressState, Customers.[Street Address 1], Customers.[Street
Address 2], Customers.City, Customers.Postcode, Customers.SendOrderForm
INTO CustomerstoprintNT
FROM Customers INNER JOIN tblOrderFormsSent ON Customers.[Customer
Number] = tblOrderFormsSent.[Customer Number]
WHERE (((Customers.AddressState)="NT") AND
((Customers.SendOrderForm)=Yes) AND
((tblOrderFormsSent.OrderFormsSent)=Max(([tblOrderFormsSent].[OrderFormsSent])
Between Date()-21 And Date()-10000)));