+ Reply to Thread
Results 1 to 7 of 7

Thread: [Solved] Query

  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    52

    [Solved] Query

    I am working on creating a Query, and need help getting it to do some math.

    In my table named Data and the column called Attended that has a series of Yes and No in a column on my table. What I need the query to do is count how many yes values there are, and count how many no values there are.

    The final thing I need it to do is add up how many yes and no values there are then subtract all of the no values.

    Any help would be greatly appreciated.
    Last edited by b50; 01-28-2011 at 03:16 PM. Reason: solved

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Help with Query

    There are probably several right answers to your question. One that comes to mind very quickly is to create two new fields in your query. In the first one type Yes: IIf([Yes/No field]="yes",1,0). In the second one, type No: IIF([yes/no field]="no',1,0). Now click on the sigma and for these two fields select Sum instead of Group By. Delete all other fields except the Yes/No field and make sure that one is set to group by.

    Alan

  3. #3
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    52

    Re: Help with Query

    OK, that is helpful, but how to do I get the total minus the Nos?

    One other thing I forgot to mention is there is also a date column, so the data is being organized by date. For exampel it is counting everything that is from 1/27/10

  4. #4
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Help with Query

    Perhaps, it would be beneficial for you to post your db so that we can see all that you have and not try to guess at a solution. Make sure to remove any sensitive or confidential data.

  5. #5
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    52

    Re: Help with Query

    I can't really post it, because it is all sensitive data, but here is hopefully a more clear explanation of what I have and what I need:

    Two of my columns are date and attended. Attended is a Yes/No, and the date is in date form. So for each date I need to group how many people attended on that date (all of the yes values for the given date), the number who did not attend (the no values for the given date). I then need to calculate how many people registered (yes plus no values).

    Thanks.

  6. #6
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Help with Query

    Ok. Look at the attached. You will need to have two queries. The first one determines the number of Yes and No by date. The second one then takes these and adds them together to give you the total registered. You only have to run the second one as it is dependent on the first. I did not know what version of access you are using so I made the example in 2002-2003 as LCD.

    Alan
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-18-2008
    Location
    USA
    Posts
    52

    Re: Query

    perfect, just needed two queries, thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0