If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
% Query
I have a table with thirty-five fields. Thirty of those fields only have two
possible options. I have another field that has a list of thirty entries(CTM's). I would like to generate a query or report that will give me the number of total option 2's selected for each of the thirty CTM's. |
#2
|
|||
|
|||
% Query
This sounds as if you may need to redesign your table structure. I am
guessing the thirty fields with only two possible options should be in a separate table with the a field identifying the option type (which you probably have in the field name) and the key field(s) from your current table. If you can't reorganize the data then you might try a union query to normalize the data and then use the union query as the source of a totals query. The problem may be that the Union Query would be too large. SELECT CTMField, OptionField1 as MyValue FROM YourTable UNION ALL SELECT CTMField, OptionField2 FROM YourTable UNION ALL .... UNION ALL SELECT CTMField, OptionField30 FROM YourTable SELECT CTMField, Count(MyValue) FROM TheUnionQuery WHERE MyValue = 2 GROUP BY CTMField Another way to do this would be to use a complex calculated field SELECT CTMField, ABS(SUM(OptionField1=2)+ SUM(OptionField2=2) + Sum(OptionField3=2)+ ....+Sum(OptionField30)=2)) as CountTwos FROM YourTable GROUP BY CTMField "T Horner" wrote in message ... I have a table with thirty-five fields. Thirty of those fields only have two possible options. I have another field that has a list of thirty entries(CTM's). I would like to generate a query or report that will give me the number of total option 2's selected for each of the thirty CTM's. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Toolbars, Drop-Down Menus | Rick | New Users | 1 | September 21st, 2005 11:17 AM |
SQL query showing diff between actual and budget | Bon | Running & Setting Up Queries | 3 | August 25th, 2005 12:07 PM |
Nested in-line Query | laura | Running & Setting Up Queries | 0 | February 11th, 2005 12:17 AM |
Big number gives error! | Sara Mellen | Running & Setting Up Queries | 8 | October 11th, 2004 02:48 AM |
Too Few Parameters error Mail Merge Access Parameter Query | Tony_VBACoder | Mailmerge | 3 | September 14th, 2004 12:15 PM |