A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

% Query



 
 
Thread Tools Display Modes
  #1  
Old October 18th, 2005, 06:32 AM
T Horner
external usenet poster
 
Posts: n/a
Default % 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  
Old October 18th, 2005, 12:41 PM
John Spencer
external usenet poster
 
Posts: n/a
Default % 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 06:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.