Results 1 to 9 of 9
  1. #1
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286

    Query to check for a CERTAIN amount of rows


    Hello i have a table with two columns, ID and Date. There needs to be 24 rows of the same date (1 row per hour) for every day of the current month. My query will need to see if there are any missing intervals. For example, find where there are <24 rows for every day of the current month. This is how my table looks for ex:


    ID Date
    123 5/29/2012
    123 5/29/2012
    456 5/30/2012
    456 5/30/2012

    ^There should be 24 rows of each ID for that particular day, so ID 123 should appear 24 times for 5/29/2012. If it is less than that, then it should appear on the query. Thanks so much!

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Just check if below gives some guidelines : The code tags are not working. Check the next reply.
    Last edited by recyan; 05-29-2012 at 10:16 PM. Reason: Code formatting not working

  3. #3
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    SELECT Table1.intID, Table1.dtDate, Count(Table1.dtDate) AS CountOfdtDateFROM Table1GROUP BY Table1.intID, Table1.dtDateHAVING (((Count(Table1.dtDate))

  4. #4
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    thanks for the help! my only question is where in this code designates that there should be 24 rows? thanks!

  5. #5
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Sorry, there is some trouble going on :The missing end part ..................Fed up trying to add;Add Less Than symbol 24 and 2 Closing Brackets at the end of code.

  6. #6
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    something like this?

    SELECT Table1.intID, Table1.dtDate, Count(Table1.dtDate) AS CountOfdtDateFROM Table1GROUP BY Table1.intID, Table1.dtDateHAVING (((Count(Table1.dtDate)) <24))

  7. #7
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Yes,

    but
    a space before FROM
    AND
    a space before GROUP
    AND
    a space before HAVING.

    Perhaps you have it already that way, but is appearing differently here.


    Trying once again,

    Code:
    SELECT 
        Table1.intID, 
        Table1.dtDate, 
        Count(Table1.dtDate) AS CountOfdtDate
    FROM 
        Table1
    GROUP BY 
        Table1.intID, 
        Table1.dtDate
    HAVING 
        (((Count(Table1.dtDate))<24));
    Edit : Thank God, things are back to normal again
    Thanks

  8. #8
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    his works great, the only thing is how do i get it to only pick up dates that are of the current month???thanks!!

  9. #9
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Have you tried something like this :

    Code:
    ..............
    ..............
    HAVING (((Month([dtDate]))=Month(Date())) AND ((Count(Table1.dtDate))<24));
    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 02-09-2012, 05:43 PM
  2. Replies: 2
    Last Post: 08-28-2011, 06:06 AM
  3. limiting amount of records
    By yaro.kobzar in forum Programming
    Replies: 1
    Last Post: 05-17-2011, 07:01 PM
  4. Query only certain rows?
    By 10 Gauge in forum Queries
    Replies: 48
    Last Post: 03-22-2011, 01:05 PM
  5. Code to spell out check amount?
    By spkoest in forum Access
    Replies: 4
    Last Post: 06-16-2009, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums