Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:43:19+00:00 2026-06-01T04:43:19+00:00

I have a table named POS_File_Detail . I would like to update Line_Number based

  • 0

I have a table named POS_File_Detail. I would like to update Line_Number based on the count of the Invoice_Number and increment by 1 for every duplicate. So basically if I have three duplicate entries with the same Invoice_Number it will update Line_Number with what duplicate number it is. Something like this

    Invoice_Number | Line_Number | Description
    0123456          1             Pepsi
    0123456          2             Chips
    0123499          1             Hot dogs
    0123456          3             Mustard

The primary key for this table is an autonumber field named Record_ID.

I’m not sure how to put this in correct syntax, but hopefully this will show you what I’m trying to do

    UPDATE POS_File_Detail 
    SET POS_File_Detail.Line_Number = Line_Number +1
    WHERE COUNT(Invoice_Number)>1;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:43:21+00:00Added an answer on June 1, 2026 at 4:43 am

    This can be really easy if you have a field or combination of fields which allow you to define the ordering of the duplicate Invoice_Number values. Without such a method, the order in which those Invoice_Number values are retrieved is arbitrary.

    You have an autonumber field named “Record_ID” as POS_File_Detail primary key.

    SELECT
        Invoice_Number,
        DCount("*", "POS_File_Detail",
            "Invoice_Number = '" & [Invoice_Number] & 
            "' AND Record_ID <= " & [Record_ID]) AS Line_Number
    FROM POS_File_Detail;
    

    Although you asked to store Line_Number in POS_File_Detail, I gave you a SELECT statement instead. I did that because it’s almost always a mistake to store derived values in the table. Better to derive Line_Number with a query whenever you need it. That way you avoid storing redundant data and ensure Line_Number is always current despite inserts, updates and deletions to POS_File_Detail.

    However if you have a sound reason to actually store Line_Number in POS_File_Detail, you can convert the SELECT to an UPDATE statement.

    UPDATE POS_File_Detail
    SET Line_Number = DCount("*", "POS_File_Detail",
        "Invoice_Number = '" & [Invoice_Number] &
        "' AND Record_ID <= " & [Record_ID]);
    

    Please make sure you really have a compelling reason to store those values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table (named tasks ) with column created_at that, basically, contains UNIX time-stamp.
I have table named highscore like this: nameQL scoreQL piotr 50 And flash game
I have table named Attendance which looks like this: Sno SecurityGroup SecurityName Designation AttendanceStatus
I have a table named datas and I'm executing a query like this: SELECT
We have a table (named QuestionBank) on which every question are stored : Id
Lets say I have table named Place with columns: placeId int not null auto_increment,
I have a table named Grades which contains 2 columns: Name and Grade. I
I have a table named Samples in my DB,and it has a column named
I have a table named table1 where datas are entered as below. slno scxid
I have a table named games: id player_a_id player_b_id player_a_result player_b_result turn 1 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.