I have two tables, a client table and an Entry table which stores transactions with a client. A client will most likely have several entries in the Entry table, but are only allowed one entry per day.
I need to make a query that will list all the clients in the Client table EXCEPT those that have an entry date of today. This will be used to make a drop-down box, and I don't want people accidently putting in more than one entry per client per day.
Here is what I have so far:
The problem is that this query will display clients who have been entered today if they also have previous Entry Dates. My best guess on how to fix this problem is to create a nested query that looks for the maximum value of the Entry Table and compares the current date against that.
I'd greatly appreciate your help!
Here is an example of what the tables look like:
Client table:
Entry table:
I need to make a query that will list all the clients in the Client table EXCEPT those that have an entry date of today. This will be used to make a drop-down box, and I don't want people accidently putting in more than one entry per client per day.
Here is what I have so far:
Code:
SELECT ClientID, [LastName] + ', ' + [FirstName] AS ClientName FROM Client WHERE (CONVERT(char(10), GETDATE(), 101) <> CONVERT(char(10), EntryDate, 101)) ORDER BY ClientName
The problem is that this query will display clients who have been entered today if they also have previous Entry Dates. My best guess on how to fix this problem is to create a nested query that looks for the maximum value of the Entry Table and compares the current date against that.
I'd greatly appreciate your help!
Here is an example of what the tables look like:
Client table:
Code:
ClientID FName LName
-------- ----- -----
1000 Bob Smith
1001 John Doe
Entry table:
Code:
EntryID ClientID EntryDate
------- -------- ---------
0001 1000 01/01/2004
0002 1000 03/02/2004
0003 1001 03/02/2004