Jump to content

Metorph

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Metorph

  1. Hey,

    I have an SQL exercise, and i have no idea how to solve this.

    I have 2 tables.

    The first table has 1 record for simplicity and 3 columns (ID, A, B). Like this:

     Row Number         ID          A             B

    1                               XY         100          10

     

    The second table has 3 record and 3 columns (ID, a1, Data):

     Row Number         ID          a1             Date

    1                               XY         30          2018.12.31

    2                               XY         30          2019.03.31

    3                               XY         30          2019.06.30

    My task to get this table:

     Row Number         ID            A              B                     a1             Date

    1                               XY            0              10                  30          2018.12.31

    2                               XY            0               0                   30          2019.03.31

    3                               XY            90             0                   30          2019.06.30

    "A" field has to be 0, except the latest line by date, which has to be the sum of "a1" (3*30).

    "B" field has to be 0, except the first line by date, which has to be equal "B" from the first table (10).

     

    Thanks for your support and help. :)

     

×
×
  • Create New...