Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    17

    Angry Unanswered: Query : price of articles

    With this kind of table

    Article Date QuantityBought Price$ QuantityUsed
    1 01/01/2005 5 10
    1 02/01/2005 20 20
    1 03/01/2005 10
    1 04/01/2005 5
    1 05/01/2005 5 30
    1 06/01/2005 5

    How do you calculate the price of the articles left knowing that :

    1) the oldest articles are used first
    2) the price changes

    5 + 20 - 10 - 5 + 5 - 5 = 10 articles left
    5 bought 05/01/2005 at the price of 30$ = 5 * 30$ = 150$
    5 bought 02/01/2005 at the price of 20$ = 5 * 20$ = 100$

    so I've got 10 articles for 150$


    How can I get the price and amount of articles left for each article in
    my table and place these informations in a formulary ?

    thx

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    "5 + 20 - 10 - 5 + 5 - 5 = 10 articles left"

    How do you determine whether articles were bought or sold? Just by the fact that they don't have a price column? And I don't see that your QuantityUsed column is being used at all.

    You need to seriously think about how your database is designed before you go too much further down this path.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •