Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql statement to find missing records

sql statement to find missing records

Scheduled Pinned Locked Moved Database
databasetutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnnysmith1
    wrote on last edited by
    #1

    I have sql statement in access database to find records -3 fields ID, name, and Date. i use

    SELECT ID,COUNT(name)AS CNT
    FROM Table1
    WHERE (((Table1.Date)=[Enter Date]
    GROUP BY ID
    HAVING COUNT(name)>1

    now I want to find records < 1 - not sure of how to start to find these-any ideas- There are supposed to be 30 records each week added - sometimes people add too many records ( the statement above helps- but if they did not add record- do not know how to figure that) Thank you,

    _ 1 Reply Last reply
    0
    • J johnnysmith1

      I have sql statement in access database to find records -3 fields ID, name, and Date. i use

      SELECT ID,COUNT(name)AS CNT
      FROM Table1
      WHERE (((Table1.Date)=[Enter Date]
      GROUP BY ID
      HAVING COUNT(name)>1

      now I want to find records < 1 - not sure of how to start to find these-any ideas- There are supposed to be 30 records each week added - sometimes people add too many records ( the statement above helps- but if they did not add record- do not know how to figure that) Thank you,

      _ Offline
      _ Offline
      _Damian S_
      wrote on last edited by
      #2

      Because it's a single table, you are a little restricted in how you can do this... One way is to use the following: SELECT ID FROM Table1 WHERE ID not in( SELECT ID FROM Table1 WHERE ((Table1.Date)=[Enter Date] GROUP BY ID HAVING COUNT(name)>1 ) Naturally this assumes that your existing query is returning the details you are after... Note also that your original query is only returning duplicates... If you want to return records where there is a single entry, your original query needs: HAVING COUNT(name) >= 1

      I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you need a laugh, check out my Vodafone World of Difference application | If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

      J 1 Reply Last reply
      0
      • _ _Damian S_

        Because it's a single table, you are a little restricted in how you can do this... One way is to use the following: SELECT ID FROM Table1 WHERE ID not in( SELECT ID FROM Table1 WHERE ((Table1.Date)=[Enter Date] GROUP BY ID HAVING COUNT(name)>1 ) Naturally this assumes that your existing query is returning the details you are after... Note also that your original query is only returning duplicates... If you want to return records where there is a single entry, your original query needs: HAVING COUNT(name) >= 1

        I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! If you need a laugh, check out my Vodafone World of Difference application | If you like cars, check out the Booger Mobile blog | If you feel generous - make a donation to Camp Quality!!

        J Offline
        J Offline
        johnnysmith1
        wrote on last edited by
        #3

        thank you

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups