+ Reply to Thread
Results 1 to 11 of 11

Thread: [Solved| Write Query

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

    [Solved| Write Query

    I am trying to write a query for the attached database that will allow me to count the number of people who left after the event ended. In my data table I have the time the people left and the date of the event. In my eventtimes tables I have the time the event ended.

    I need a query that will calculate how many, who attended the event stayed past until or past the end time.

    Thanks,
    Attached Files Attached Files
    Last edited by b50; 01-31-2011 at 05:43 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: Need Help Writing Query

    I don't see an eventtimes table in this db nor do I see when the participants left. Why don't you dummy up this database to look the way you want the tables to look and then we can offer up a viable solution.

    Alan

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

    Re: Need Help Writing Query

    There is a table called eventtimes. which has the date of the event, and the end time.

    There is a data table which has whether or not the person attended the event (yes/no) the date of the event they attended, the name of the event they attended, and the time they left the event.

    I need to know how to calculate for those who attended the event (with the event date being the unique identifier) whether or not they left early. So if the leave time in the data table is less than the end time in the eventtimes table then it will count how many people left early. THen i also need it to count how many people stayed past the end time (leave time>=end time)

    Hopefully that clears it up a bit.

  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: Need Help Writing Query

    Show us a sample database. It is difficult to visualize what you are saying. It is easier to see what you are attempting to do. It will answer questions, how are the tables related (joined), formatted, what other fields have to be taken into consideration, etc. Take the time to dummy up the database so that it mirrors your production database but does not compromise your sensitive data. This is important if you expect to get some help here as many of us failed our mind reading exam. Othewise, we are only guessing at what you have and what you want.

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

    Re: Need Help Writing Query

    There is a sample database attached to my first post. That has it all in there...

  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: Need Help Writing Query

    See attached. Created an aggregate select query.
    Attached Files Attached Files

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

    Re: Need Help Writing Query

    Thanks for your help.

    Maybe you should have actually looked at the attachment before you started complaining about me not having a dummed down one, when it turned out to be exactly what you needed.

  8. #8
    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: [Solved| Write Query

    B50;
    I looked at the attachment the first time you posted and it appeared to have no data that you were talking about. It was the same file that I had created earlier in your other thread. If you subsequently changed the file, there would be no way for me to know that unless you told me. Therefore, my request that you provide the data requested. I apologize for any confusion, but I am only trying to help you.

    Alan

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

    Re: [Solved| Write Query

    I apologize too. I never changed the attachment, so I don't know what happened there. I was just really confused...

    I forgot that I needed to do this or I would have included it in my last post.. Anyways another quick question is there anyway that I add a between statement to that last query?

    See example attached. I like what you created so far, but I need to add another column that lets me know count of people that left between breaktime (new row on the eventtimes table) and the endtime.

    So it will count the number of people who left between breaktime and endtime for a given event.

    Thank you so much for all of you help.
    Attached Files Attached Files

  10. #10
    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: [Solved| Write Query

    Here you go. Amended Query1 to address the request.
    Attached Files Attached Files

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

    Re: [Solved| Write Query

    Perfect. Thank you very much for you help.

+ 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