SQL Statment

  • I need help to create the right SQL statment for my issue.

    In the table are two different values separated by counter.

    FIELDNR

    - the Cardnr (021)

    - the percent to Cardnr (022)

    - PSNR is Personalnr from each Employee

    - PFLFDNR is a seq. number for the fields 21 and 22 it show how many rows each Fieldnr already has

    The values are identified with the help of the date field PFGLTFROM and PFGLTTO.

    You must select of both records from a Personalnr always one active date out.

    Example:

    Rows for Persnr=64 and Cardnr=21 in different times (but we need only one record which is valid from and to date

    FIRMA PSNR FIELDNR PFLFDNR VALUE PFGLTFROM PFGLTTO

    1 64 021 1 2901009749 20110101 20140531

    1 64 021 2 24 20140601 20321231

    Rows for Persnr=64 and Cardnr=22 Percent in different times (but we need only one record which is valid from and to date

    1 64 022 1 1 20110101 20120731

    1 64 022 2 0 20120801 20120907

    1 64 022 3 0.77 20120908 20120930

    ............................

    1 64 022 10 1 20140816 20320101

    I select the 2.row from Field=021 because it has the actual date PFGLTFROM=2014.06.01 PFGLTTO=2032.12.31

    and the value from Fieldnr=22 is 1 because it has the actual date PFGLTFROM=20140816 PFGLTTO=20320101

    This should be the Output

    FIRMA PSNR FELDNR PFLFDNR Value1 Value2 PFGLTFROM PFGLTTO

    1 64 021 2 24 1 20140601 20321231

    I hope I could explain my problem 🙂

    Thx

    zero1de

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply