Additional procedure Subquery?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with patient accounts, dates, and procedure codes. I want to run a query that looks for a certain procedure code (that part is easy), but when I find one, I want to look in the remaining data (more recent dates) to find that procedure code again.

For example if I find that account 1234 has procedure code 98000 on 4/1/2003. I want to look for that account (1234) and that procedure code (98000) between the dates of 4/2/2003 and today (7/22/2004).

How is this best tackled? Subquery, two separate queries, or something else?

Thanks,

MEG
 
If you are simply trying to find the most recent date for
every account/procedure code combination in the table, then
try something along the lines of

SELECT account, procedureCode, procedureDate
FROM YourTable AS T1
WHERE procedureDate IN (SELECT Max(procedureDate) FROM
YourTable Where account = T1.account AND procedureCode =
T1.procedureCode)

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a table with patient accounts, dates, and procedure
codes. I want to run a query that looks for a certain
procedure code (that part is easy), but when I find one, I
want to look in the remaining data (more recent dates) to
find that procedure code again.
For example if I find that account 1234 has procedure code
98000 on 4/1/2003. I want to look for that account (1234)
and that procedure code (98000) between the dates of
4/2/2003 and today (7/22/2004).
 
Back
Top