Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Remove all but the most current records

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Remove all but the most current records

    I have a table of around 7,000 traffic charges, downloaded from our local district court's database. Unfortunately, when a fine is amended, they add a new record with the new fine and the effective date, but leave the old data for historical purposes. That in turn, makes the table much bigger than it needs to be (for our agency purposes), and displays unnecessary data.

    I'm looking for a way to run an opereration that would group all of the matching charges (records) together, and delete all but the newest ones, keeping in mind the newest dates on some of them may be 2001 or older.

    Attached is a screen shot of one such charge. The newest date on this charge is 2005.
    Last edited by Rich Hartnett; 11-17-2007, 03:50 PM.
    Sergeant Richard Hartnett
    Hyattsville City Police Department
    Maryland

    #2
    Re: Remove all but the most current records

    Rich,

    You can use the <TBL>.DELETE_RANGE() function.

    e.g.
    tbl = table.current()
    tbl.DELETE_RANGE("Date_Begin<{1/1/01}")
    parentform.resynch()
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com


    Comment


      #3
      Re: Remove all but the most current records

      Rich,

      Have you already imported these records?? If so I imagine you would have had to create or import to a parent table (with person field) and a child table (with person field and all fines associated with the person field).

      When doing this you could only import however many child records you wanted to using various means, easiest which would be simply to fetch_first in each of the child records of each parent which would give you the latest record if you first inverted the order to show the latest records first--could be done with rec_no if in order or invert of the date. If more records wanted then use however many fetch_next()s you want in each child record.

      If you already have imported these records then another similar method would work but would need to know what you did.
      Mike
      __________________________________________
      It is only when we forget all our learning that we begin to know.
      It's not what you look at that matters, it's what you see.
      Henry David Thoreau
      __________________________________________



      Comment


        #4
        Re: Remove all but the most current records

        Code:
        topparent.queryrun("top_records(1)".and.other filter criteria...,"","","No","",.f.)
        This will query for the top-most record

        Comment


          #5
          Re: Remove all but the most current records

          But G,

          that would work in a few situations but not knowing how Rich has imported these records it would not necessarily work in quite a few cases....need to have Rich tell us more in order to address his problem in a specific way.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #6
            Re: Remove all but the most current records

            Might this really be a two step process... i.e. (1) mark all the "matching" records; and then (2) delete the oldest but only if marked? Doesn't sound like a single operation will be able to do both.

            Comment


              #7
              Re: Remove all but the most current records

              Mike:
              In my fast reading I might have missed something, but I think I got the gist of it. He wants only the most recent record of the children to be preserved. Is there more to it than that?

              I will garner some more patience and re-read it.

              Later:
              Re-read it; No there is nothing more, except perhaps one loose item:
              Define newest?
              One record? more than one? meet certain dates?

              Tom:
              Yes, you are correct (pending further head scratching). I believe something simillar to what you describe was suggested for a simillar question in the past.

              Later..
              After minor head-scratching:
              You could make a very simple script that orders all children sorted by the linking field then by dates
              go down the records, preserving the ones that meet the desired criteria and deleting the rest..
              Last edited by G Gabriel; 11-17-2007, 04:49 PM.

              Comment


                #8
                Re: Remove all but the most current records

                G,

                Most likely what you last suggested is along the same lines of what I would have if he already has imported them and does have the linking field.

                But he did mention a caveat about "deleting all but the newest ones" and so is still easy but does have to be considered if by the plural he means more than one child per parent to be preserved..
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: Remove all but the most current records

                  if he already has imported them and does have the linking field
                  Sounds like he already did:
                  downloaded from our local district court's database. Unfortunately, when a fine is amended, they add a new record
                  But he did mention a caveat about "deleting all but the newest ones"
                  The pleural could be:
                  1-The most recent child record of all parents
                  2-Several child records per parent.

                  Needs clarification..

                  Comment


                    #10
                    Re: Remove all but the most current records

                    Hi gang,

                    This is a simple single table, containing traffic citation charges. There is no parent table or child table relationship, just a single table. I just need to eliminate the duplicate charges, leaving only the most recent.

                    I've attached a small snipped of 200 records from that table so you can see what I'm talking about.

                    The field called "Sec_sub_para" (short for Section, Subsection, and Paragraph) is the one that contains the data that will be recognized as duplicate. Next to it is a field called "Date_Begin," and that is the date that needs to be used to determine which of those duplicate charges is the NEWEST. The rest need to be deleted.

                    I hope this helps clarify what I'm trying to do.

                    Rich
                    Sergeant Richard Hartnett
                    Hyattsville City Police Department
                    Maryland

                    Comment


                      #11
                      Re: Remove all but the most current records

                      On further head scratching.. yes it can be done in one single step, it's called summarize.
                      Last edited by G Gabriel; 11-17-2007, 06:16 PM.

                      Comment


                        #12
                        Re: Remove all but the most current records

                        I tried to open your zip file, but the table seems to be corrupted.

                        See attached screen shot.
                        Sergeant Richard Hartnett
                        Hyattsville City Police Department
                        Maryland

                        Comment


                          #13
                          Re: Remove all but the most current records

                          I'm probably missing something, Rich. Why doesn't the simple solution I posted above work?
                          Peter
                          AlphaBase Solutions, LLC

                          [email protected]
                          https://www.alphabasesolutions.com


                          Comment


                            #14
                            Re: Remove all but the most current records

                            I never tried it. Before I got a chance, I saw Gabriel's post about running a summarize operation, and it sounded like that would solve it, which is does.

                            I couldn't get Gabe's zipped file to open, but I figured out the correct layout for the summarize operation to return the records the way I need them, and it works fine.

                            As always, thanks to everyone.
                            Sergeant Richard Hartnett
                            Hyattsville City Police Department
                            Maryland

                            Comment


                              #15
                              Re: Remove all but the most current records

                              Originally posted by Rich Hartnett View Post
                              I'm looking for a way to run an opereration that would group all of the matching charges (records) together, and delete all but the newest ones, keeping in mind the newest dates on some of them may be 2001 or older.
                              Peter,
                              I was all about thinking your method would work well, except then thought there is a bit more to it than that. This is a group of tickets for the same fine. There would have to be a filter that identifies the last record for the specific fine, exclude that record as the most current, and delete the remainder.
                              Mike W
                              __________________________
                              "I rebel in at least small things to express to the world that I have not completely surrendered"

                              Comment

                              Working...
                              X