That is correct they will always be in separate rows. What I was thinking
of doing was making a make table query that pulls every "den1" row to
isolate those IDs. Link that table back to the original Plan table and use
iif(plan=med1,medical,plan). The one thing I don't know how to do is make
an Access query to return all rows from table2 where table1 ID doesn't equal
table2 ID. The reason I say this is because once I change the med1 to
medical I need to return all rows with eff_date =date()-1 so I was thinking
of making a table of all of the medical rows an all other rows for those
ID's then append the remaining rows.
>I can't be sure from the example you gave, but it seems like you could look
>at this a different way.
[quoted text clipped - 39 lines]
>> 4 medical 3
>> 5 med1 1
Ken Sheridan - 14 Feb 2008 11:20 GMT
If I understand you correctly I think you should be able to do this without
the need to create a table by using a UNION ALL operation, each part of which
uses a subquery to check if any other relevant row for the current ID exists
or not:
SELECT ID, Plan, Level
FROM YourTable As T1
WHERE Plan <> “med1”
OR (Plan = “med1”
AND NOT EXISTS
(SELECT *
FROM YourTable AS T2
WHERE Plan = “den1”))
UNION ALL
SELECT ID,”Medical”, Level
WHERE Plan = “med1”
AND EXISTS
(SELECT *
FROM YourTable AS T2
WHERE
Plan = “den1”);
Ken Sheridan
Stafford, England
> That is correct they will always be in separate rows. What I was thinking
> of doing was making a make table query that pulls every "den1" row to
[quoted text clipped - 48 lines]
> >> 4 medical 3
> >> 5 med1 1
Ken Sheridan - 14 Feb 2008 18:18 GMT
Doh! I really messed that up (I'll blame the cable company engineer who
interrupted me while I was drafting my reply). Firstly, I didn't correlate
the subqueries, and secondly I missed the FROM clause out of the second part
of the query. It should have been:
SELECT ID, Plan, Level
FROM YourTable As T1
WHERE Plan <> "med1"
OR (Plan = "med1"
AND NOT EXISTS
(SELECT *
FROM YourTable AS T2
WHERE T2.ID = T1.ID
AND Plan = "den1"))
UNION ALL
SELECT ID,"Medical", Level
FROM YourTable As T1
WHERE Plan = "med1"
AND EXISTS
(SELECT *
FROM YourTable AS T2
WHERE T2.ID = T1.ID
AND Plan = "den1");
Apologies for the confusion.
Ken Sheridan
Stafford, England
Pat_RI - 15 Feb 2008 02:09 GMT
Thanks. Those damn cable guys will do it all the time.
> Doh! I really messed that up (I'll blame the cable company engineer who
> interrupted me while I was drafting my reply). Firstly, I didn't
[quoted text clipped - 26 lines]
> Ken Sheridan
> Stafford, England