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. Finding lowest integer in an Access Database

Finding lowest integer in an Access Database

Scheduled Pinned Locked Moved Database
databasetutorialquestion
4 Posts 3 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.
  • P Offline
    P Offline
    pjholliday
    wrote on last edited by
    #1

    I am using a MS Access Database. Can anyone suggest some SQL to find the lowest unused number from one a column, say 'Quantity' for example? Thanks

    L 1 Reply Last reply
    0
    • P pjholliday

      I am using a MS Access Database. Can anyone suggest some SQL to find the lowest unused number from one a column, say 'Quantity' for example? Thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      pjholliday wrote: Can anyone suggest some SQL to find the lowest unused number What do you mean by unused number? Do you mean that the number that is the lowest value in the table. If so, try the following statement: SELECT * tblTest ORDER BY tblTest.Quantity The above statement will sort the column Quantity from the lowest value to the highest value (suppose from 0 to 100). Then the first record of your database will be the lowest value.


      A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

      P 1 Reply Last reply
      0
      • L Lost User

        pjholliday wrote: Can anyone suggest some SQL to find the lowest unused number What do you mean by unused number? Do you mean that the number that is the lowest value in the table. If so, try the following statement: SELECT * tblTest ORDER BY tblTest.Quantity The above statement will sort the column Quantity from the lowest value to the highest value (suppose from 0 to 100). Then the first record of your database will be the lowest value.


        A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

        P Offline
        P Offline
        pjholliday
        wrote on last edited by
        #3

        What I mean by unused number is for example I have the following numbers in my column 1 2 3 4 6 7 8 I want it to return the value 5 because that is the lowest value that does not appear in the column. Is it possible to write a query to do that?

        E 1 Reply Last reply
        0
        • P pjholliday

          What I mean by unused number is for example I have the following numbers in my column 1 2 3 4 6 7 8 I want it to return the value 5 because that is the lowest value that does not appear in the column. Is it possible to write a query to do that?

          E Offline
          E Offline
          Edbert P
          wrote on last edited by
          #4

          It is, if you have another table with integer values. The SQL will be like this:

          SELECT MIN(tblInteger.Number)
          FROM tblInteger
          WHERE tblInteger.Number NOT IN
          (
          SELECT Numbers
          FROM tblData
          )

          tblData will be the table you described while tblInteger will have integer numbers you use. So far that's the only way I can think of, maybe others can help? Edbert P. Sydney, Australia.

          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