Expression in a query

R

Radhika

I have a table called 'tbl_TEPRecords' with three fields of interest ,
'ID#'(primary field), 'DateOfVisit' and 'VPInsertionDate'. I want to use this
table to create a query that finds the fields where VPInsertionDate on the
second DateOfVisit for each ID# is not equal to the First DateOfVisit. Below
is an example of such a combination:

ID# DateOfVisit VPInsertionDate
111111 01/01/2001
111111 02/01/2001 011/01/2001 (instead of 01/01/2001)

How can I go about doing this?

Thankyou,
Radhika
 
B

Brendan Reynolds

Radhika said:
I have a table called 'tbl_TEPRecords' with three fields of interest ,
'ID#'(primary field), 'DateOfVisit' and 'VPInsertionDate'. I want to use
this
table to create a query that finds the fields where VPInsertionDate on the
second DateOfVisit for each ID# is not equal to the First DateOfVisit.
Below
is an example of such a combination:

ID# DateOfVisit VPInsertionDate
111111 01/01/2001
111111 02/01/2001 011/01/2001 (instead of 01/01/2001)

How can I go about doing this?

Thankyou,
Radhika


This should do it I think ...

SELECT tblTest.[id#], Min(tblTest.dateofvisit) AS MinOfdateofvisit,
Min(tblTest.vbpinsertiondate) AS MinOfvbpinsertiondate
FROM tblTest
GROUP BY tblTest.[id#]
HAVING (((Min(tblTest.dateofvisit))<>Min([tblTest].[vbpinsertiondate])));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Autofill query 0
Merge records with same number 0
Complex query 4
Using DateAdd and IIF conditions in a Query 2
Avg in a query 3
Expression in query 3
Date query 4
Taking the sum between two dates 2

Top