+ Reply to Thread
Results 1 to 12 of 12

Access query to do Count of distinct sites with Sum of duration

  1. #1
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Access query to do Count of distinct sites with Sum of duration

    Hi,

    Need your help on the following..

    I have a assets database in Access. Want to calculate the number of failure incidents happened on a particular asset and for how much duration such failure was through MS access SQL...

    Giving the database structure in the file attached. Along with the expected resolution...

    Kindly assist on this..

    Thanks in advance...
    Attached Files Attached Files
    Last edited by NBVC; 04-26-2011 at 10:05 AM. Reason: OP changed title in wrong post.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Access Query

    Suggest you post your actual db so that we can manipulate the queries. I envision a couple of aggregate queries and finally a union query to bring it all together. If you post the actual db, then the exact SQL statements can be provided.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Access Query

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Re: Access Query

    Hi,

    Thanks for the response. Attaching the actual DB for the resolution..

    Applogies for not using the title of the query approprietly...Will take this into consideration in all my post going forward...

    Hope to get the response soon on this...

    Thanks,
    Attached Files Attached Files
    Last edited by excelhelp18; 04-26-2011 at 06:34 AM.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Access Query

    Please change the current thread title.

  6. #6
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Re: Access query to do Count of distinct sites with Sum of duration

    Quote Originally Posted by NBVC View Post
    Please change the current thread title.
    Title changed as requested.

    please do the needful.

    Thanks

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Access query to do Count of distinct sites with Sum of duration

    This SQL statement should give you the expected results that you requested.

    Please Login or Register  to view this content.
    Open a new query, add the Assets table. Click on the drop down in the upper left corner of the QBE and select SQL. Paste the above code and then switch back to design to see how you would have designed in the QBE. Click on the data sheet icon for results.

    Alan

  8. #8
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Re: Access query to do Count of distinct sites with Sum of duration

    Thanks for the reply..

    The query provided by you, does count the total instances of Assets failure with total duration...what I am looking for is the count of unique/distinct sites instances of assets failure with total duration...

    Have attached the excel as well as the access DB for your support...Excel with provide you with the exact solution I am looking for through using access..

    Thanks in advance..
    Attached Files Attached Files

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Access query to do Count of distinct sites with Sum of duration

    This appears to be close. You will need to check the details.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Re: Access query to do Count of distinct sites with Sum of duration

    Quote Originally Posted by alansidman View Post
    This appears to be close. You will need to check the details.
    Thanks for the reply..but this is not as per my requirement..

    For Cluster "CHAMBA", the CountOfPIU Failure is showing 2 whereas it should be 1 as I am looking for distinct SiteId (RKAT01) having the failure.

    Your response is taking the count of SiteId (RKAT01) as 2..want to capture the siteId count as unique...

    Similarly for cluster "NAHAN", the SiteId (KAMB02) is repeated and hence it should be counted as 1 and subsequently CountOfDG Failure for "NAHAN" cluster should be 8 and not 9 as shown by the query you developed..

    Kindly help on this..
    Thanks..

  11. #11
    Forum Contributor
    Join Date
    03-18-2008
    Posts
    123

    Re: Access query to do Count of distinct sites with Sum of duration

    Quote Originally Posted by excelhelp18 View Post
    Thanks for the reply..but this is not as per my requirement..

    For Cluster "CHAMBA", the CountOfPIU Failure is showing 2 whereas it should be 1 as I am looking for distinct SiteId (RKAT01) having the failure.

    Your response is taking the count of SiteId (RKAT01) as 2..want to capture the siteId count as unique...

    Similarly for cluster "NAHAN", the SiteId (KAMB02) is repeated and hence it should be counted as 1 and subsequently CountOfDG Failure for "NAHAN" cluster should be 8 and not 9 as shown by the query you developed..

    Kindly help on this..
    Thanks..
    Can someone look into this at earliest....??

    Need to prepare a report for team..Thanks...

  12. #12
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114

    Re: Access query to do Count of distinct sites with Sum of duration

    Hi,

    Use Query: "qry_Result" should give you what you want.

    Tony
    Attached Files Attached Files

+ 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.6.0 RC 1