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

  • SEARCH
  • Home
  • 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 4239166
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:59:55+00:00 2026-05-21T02:59:55+00:00

I have a database in which I store product sales. My sales table is

  • 0

I have a database in which I store product sales. My sales table is made up of the following fields: [saleID], [itemCode], [Date], [storeID], [quantitySold]. The problem is I want the user to be able to insert a payment for multiple saleIDs.

Prices come from the items table but there may be a discount if multiple items are purchased. I want to be able to store a finalPayment field and multiple sales connected to it, then group the sales by the specific finalPayment. However there could be same sum finalPayments that do not belong to the same sales batch so I cannot group by finalPayment as a field in the sales table.

I could create a finalPayments table and every time a multiple item sale and discount is made, store a new final payment in it, retrieve the last finalPaymentID and then store it in the sales table (in a new field [finalPaymentID] that I will create) for every sale that belongs to it. Then i could group sales by finalPaymentID.

Could the last finalPaymentID in the table be created by some other store? Can there be a concurrency problem? Do I need to lock the table in some way until the finalPaymentID is retrieved and stored in the sales table? How would you implement this?

  • 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-05-21T02:59:55+00:00Added an answer on May 21, 2026 at 2:59 am

    I actually did with the payments table. I used
    string insertSQL = “INSERT INTO [payments ] ([paymentSum]) VALUES (@paymentSum);SELECT @@Identity”;

    and then stored the paymentID retrieved into the sales table for each sale that is part of the batch.

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

Sidebar

Related Questions

I have a database that looks like this: Product: PK(ProductId), ProductName....... Store: PK(StoreId), StoreName......
I have a database which needs to store year ranges (such as lifespan) which
I have a database in which I'd like to store an arbitrary ordering for
I have a database in my application in which I store something like a
I currently have a MySQL database which I was hoping to use to store
I have to design a database which will allow me store data in multiple
I have a database which stores (among other things), the following pieces of information:
I have a database table A which stores records, A has a primary key
I'm using LINQ to SQL and have a database table called Product with 20
I have a database design where i store image filenames in a table called

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.