I want to run a query, rather an easy one but I'm a beginner at it so I am not sure how to actually condense all this information.
I have the following fields that I really care about:
Room/Location
Schedule
Pre
Post
I have the following Rooms
Compounding
Ointment
Liquid
AIrlock
Corridor
Gowning
I want to see the total samples of the day by saying If the room is compounding, and it is schedule A and the pre is yes and the post is yes then there should be 21 samples.
There will be a lot of different combination of the thing I said above, this was the code so far:
I know, too many ifs, but I had no other clue how to do it, and up to a certain point, it told me that it was too complex.. Whats another way I can reduce the information and still see the total number of samples each day:
SELECT [Rodac Plates (2008)].Date, [Rodac Plates (2008)].Schedule, [Rodac Plates (2008)].[Room/Location], (IIf([Room/Location]="Compounding" And ([Schedule]="A" Or [Schedule]="C") And [Pre]="Yes" And [Post]="Yes",21,(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="D") And [Pre]="Yes" And [Post]="Yes","20",(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="D") And [Pre]="Yes","14",(IIf([Room/Location]="Compounding" And ([Schedule]="A" Or [Schedule]="C") And [Pre]="Yes","15",(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="A" Or [Schedule]="C" Or [Schedule]="D") And [Post]="Yes","6",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Pre]="Yes" And [Post]="Yes","24",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Pre]="Yes","16",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Post]="Yes","8")))))))))))))))) AS [Total Number of Samples]
FROM [Rodac Plates (2008)];
I have the following fields that I really care about:
Room/Location
Schedule
Pre
Post
I have the following Rooms
Compounding
Ointment
Liquid
AIrlock
Corridor
Gowning
I want to see the total samples of the day by saying If the room is compounding, and it is schedule A and the pre is yes and the post is yes then there should be 21 samples.
There will be a lot of different combination of the thing I said above, this was the code so far:
I know, too many ifs, but I had no other clue how to do it, and up to a certain point, it told me that it was too complex.. Whats another way I can reduce the information and still see the total number of samples each day:
SELECT [Rodac Plates (2008)].Date, [Rodac Plates (2008)].Schedule, [Rodac Plates (2008)].[Room/Location], (IIf([Room/Location]="Compounding" And ([Schedule]="A" Or [Schedule]="C") And [Pre]="Yes" And [Post]="Yes",21,(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="D") And [Pre]="Yes" And [Post]="Yes","20",(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="D") And [Pre]="Yes","14",(IIf([Room/Location]="Compounding" And ([Schedule]="A" Or [Schedule]="C") And [Pre]="Yes","15",(IIf([Room/Location]="Compounding" And ([Schedule]="B" Or [Schedule]="A" Or [Schedule]="C" Or [Schedule]="D") And [Post]="Yes","6",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Pre]="Yes" And [Post]="Yes","24",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Pre]="Yes","16",(IIf([Room/Location]="Liquid" And ([Schedule]="A" Or [Schedule]="B" Or [Schedule]="C" Or [Schedule]="D") And [Post]="Yes","8")))))))))))))))) AS [Total Number of Samples]
FROM [Rodac Plates (2008)];