betachristopher
Programmer
I am running a crosstab query and am having a problem getting the totals I am looking for. The crosstab works fine, but I am trying to get monthly totals of a specific lab test, and I need it to count some records in more than one place.
In my table, there is a field that lists one of the following: High Risk, Low Risk or Both. I want to show totals of the High Risk and Low Risk. If a record is listed as Both, I want it added to the total of both the High Risk and Low Risk.
I added a field in my query to properly label the totals: Switch(TABLE!FIELD In (“High Risk”, “Both”),"HR", TABLE!FIELD In (“Low Risk”, “Both”),"LR")
This doesn’t work because it first counts anything marked as “Both” as “HR” and doesn’t count it again as “LR”.
If I make these two separate queries and create a union query, I am able to get the results I want, but I am looking for a better solution.
I am using MS Access 2007 with a SQL 2000 backend. I hope this is enough information to help me.
In my table, there is a field that lists one of the following: High Risk, Low Risk or Both. I want to show totals of the High Risk and Low Risk. If a record is listed as Both, I want it added to the total of both the High Risk and Low Risk.
I added a field in my query to properly label the totals: Switch(TABLE!FIELD In (“High Risk”, “Both”),"HR", TABLE!FIELD In (“Low Risk”, “Both”),"LR")
This doesn’t work because it first counts anything marked as “Both” as “HR” and doesn’t count it again as “LR”.
If I make these two separate queries and create a union query, I am able to get the results I want, but I am looking for a better solution.
I am using MS Access 2007 with a SQL 2000 backend. I hope this is enough information to help me.