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. Help with access query

Help with access query

Scheduled Pinned Locked Moved Database
helpdatabasetutorial
5 Posts 4 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.
  • S Offline
    S Offline
    sarang_k
    wrote on last edited by
    #1

    Hi all, I am having a table in which one field data type is text and the data stored in it is characters + numbers for example SD01TU9,SD01TU8,SD01TU10. Now the problem is i want the max from it.As in the above example the max should show SD01TU10 but when i use max function on that field it shows SD01TU9. Please any one can solve it. Thanks in advance.

    M _ R 3 Replies Last reply
    0
    • S sarang_k

      Hi all, I am having a table in which one field data type is text and the data stored in it is characters + numbers for example SD01TU9,SD01TU8,SD01TU10. Now the problem is i want the max from it.As in the above example the max should show SD01TU10 but when i use max function on that field it shows SD01TU9. Please any one can solve it. Thanks in advance.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You have a number of choices, you have a requirement to do numerical operations on a field with mixed data. Create another field and extract the numeric component from the mixed field Use a view (query in Access I think) to do the same thing just don't store it Go back to your initial design that put the mixed data in there and address the problem at the source. As your data seems to be consistent (SD and TU) you could do this with nested replace statements. It gets a little tricky if your text data changes from the standard, then use regex.

      Never underestimate the power of human stupidity RAH

      _ 1 Reply Last reply
      0
      • S sarang_k

        Hi all, I am having a table in which one field data type is text and the data stored in it is characters + numbers for example SD01TU9,SD01TU8,SD01TU10. Now the problem is i want the max from it.As in the above example the max should show SD01TU10 but when i use max function on that field it shows SD01TU9. Please any one can solve it. Thanks in advance.

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

        If all the strings include the letters "TU" before the numbers at the end, you could use a combination of instr() and len() and right() to get what you need... I'm doing this from memory and without access to Access to test, but it would be something like this:

        clng(right(FIELDNAME, len(FIELDNAME)-instr(FIELDNAME, "TU")))

        Which basically says locate the position of TU in the field, then take the characters to the right of them, convert to long and then you can happily find the max of those numbers.

        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!!

        1 Reply Last reply
        0
        • M Mycroft Holmes

          You have a number of choices, you have a requirement to do numerical operations on a field with mixed data. Create another field and extract the numeric component from the mixed field Use a view (query in Access I think) to do the same thing just don't store it Go back to your initial design that put the mixed data in there and address the problem at the source. As your data seems to be consistent (SD and TU) you could do this with nested replace statements. It gets a little tricky if your text data changes from the standard, then use regex.

          Never underestimate the power of human stupidity RAH

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

          Are you stalking me? :laugh:

          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!!

          1 Reply Last reply
          0
          • S sarang_k

            Hi all, I am having a table in which one field data type is text and the data stored in it is characters + numbers for example SD01TU9,SD01TU8,SD01TU10. Now the problem is i want the max from it.As in the above example the max should show SD01TU10 but when i use max function on that field it shows SD01TU9. Please any one can solve it. Thanks in advance.

            R Offline
            R Offline
            riced
            wrote on last edited by
            #5

            If you have the option, you might consider ensuring that the data all have the same number of digits at end. E.g. use SD01TU09 instead of SD01TU9, or SD01TU009 if there can be three digits. This would mean you don't have to monkey around with substrings.

            Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

            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