Hi
I've only just started to use and learn SQL and think its a great and powerful language. Unfortunately I'm trying to bite off a bit more than I can chew but its something I need to do.
I'm trying to run this query in access but I keep getting an error message and cant see why. The message is 'Invalid Use of '.', '!', () in the expression.
SELECT TEMPLATE.NHI, TEMPLATE.Surname, TEMPLATE.Dept, TEMPLATE.ID, TEMPLATE.[Final Diag]
FROM TEMPLATE
WHERE (((TEMPLATE.Dept)="Cytology") AND ((TEMPLATE.[Final Diag])="LG" OR "Normal"))
(SELECT TEMPLATE.NHI FROM TEMPLATE WHERE ((TEMPLATE.Dept)="Histology") AND ((TEMPLATE.[Final Diag])="HG"));
What I'd like to happen is for the query to find any records in the table where the dept is 'histology' and the final diagnosis is 'HG'. Once its found those, I'd then like it to find any records which have a matching NHI (there can be multiple records with the same NHI in the table) but this time where the Dept is 'Cytology' and the Final Diagnosis is "LG" or "Normal".
At the end I need to know that all the records in front of me are Cytology and either 'LG' or 'Normal' but that in the background (I dont neccessarily need to see them) the same patient had a 'HG' histolgy result.
Running one or other Select statement works fine but I cant seem to get them to play nicely together.
Would someone be able to help me and tell where I'm going wrong
thanks
Steve
I've only just started to use and learn SQL and think its a great and powerful language. Unfortunately I'm trying to bite off a bit more than I can chew but its something I need to do.
I'm trying to run this query in access but I keep getting an error message and cant see why. The message is 'Invalid Use of '.', '!', () in the expression.
SELECT TEMPLATE.NHI, TEMPLATE.Surname, TEMPLATE.Dept, TEMPLATE.ID, TEMPLATE.[Final Diag]
FROM TEMPLATE
WHERE (((TEMPLATE.Dept)="Cytology") AND ((TEMPLATE.[Final Diag])="LG" OR "Normal"))
(SELECT TEMPLATE.NHI FROM TEMPLATE WHERE ((TEMPLATE.Dept)="Histology") AND ((TEMPLATE.[Final Diag])="HG"));
What I'd like to happen is for the query to find any records in the table where the dept is 'histology' and the final diagnosis is 'HG'. Once its found those, I'd then like it to find any records which have a matching NHI (there can be multiple records with the same NHI in the table) but this time where the Dept is 'Cytology' and the Final Diagnosis is "LG" or "Normal".
At the end I need to know that all the records in front of me are Cytology and either 'LG' or 'Normal' but that in the background (I dont neccessarily need to see them) the same patient had a 'HG' histolgy result.
Running one or other Select statement works fine but I cant seem to get them to play nicely together.
Would someone be able to help me and tell where I'm going wrong
thanks
Steve