Query Generation - repeating previous value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Uncle Mike

    Query Generation - repeating previous value

    Hi all,

    I can't tell if I'm just being a spaccer, or whether this is tricky.
    Here goes.

    (Please note - this is a dummy example, for ease of explaining.)

    So, I have a table with three fields:

    ID
    Date
    Value

    ID and Date together are the primary key. Essentially what it's for is
    this: ID is, say, a product (oranges, apples, pears, grapes). Value is
    the price of said product. What I want is the table to contain
    information just when the price changes. So there's an entry for each
    product at the start of time, then just new records when the price
    changes.

    Then, I want to have a query/report/printable data showing me the
    price of each product over time, with it filling in the blanks where
    the price has stayed the same.


    So, we'd have something like this:

    Table Data
    ID........Date. ........Value
    Oranges...01/01/2004...30
    Oranges...01/02/2004...32
    Oranges...01/04/2004...35
    Apples....01/01/2004...23
    Apples....01/03/2004...24
    Apples....01/04/2004...25


    And I want to turn that into

    Query Output
    Date......01/01/2004...01/02/2004...01/03/2004...01/04/2004
    Oranges...30... ........32..... ......32....... ....35
    Apples....23... ........23..... ......24....... ....25


    So, what do I need to do in terms of queries, guys? I'm using Access
    97, if it makes a huge amount of difference.
  • John Winterbottom

    #2
    Re: Query Generation - repeating previous value

    "Uncle Mike" <billy.bob20@nt lworld.com> wrote in message
    news:9a54e308.0 404230618.3c614 b13@posting.goo gle.com...[color=blue]
    > Hi all,
    >
    > I can't tell if I'm just being a spaccer, or whether this is tricky.
    > Here goes.
    >
    > (Please note - this is a dummy example, for ease of explaining.)
    >
    > So, I have a table with three fields:
    >
    > ID
    > Date
    > Value
    >
    > ID and Date together are the primary key. Essentially what it's for is
    > this: ID is, say, a product (oranges, apples, pears, grapes). Value is
    > the price of said product. What I want is the table to contain
    > information just when the price changes. So there's an entry for each
    > product at the start of time, then just new records when the price
    > changes.
    >
    > Then, I want to have a query/report/printable data showing me the
    > price of each product over time, with it filling in the blanks where
    > the price has stayed the same.
    >[/color]

    Use a calendar table with all the dates you are ever likely to need and join
    to this table iin your query.


    Comment

    Working...