Results 1 to 2 of 2

Thread: hoogste volgnummer per code

  1. #1

    hoogste volgnummer per code

    Hallo,

    Ik heb onderstaande tabel gemaakt:

    [BIPS.KlntBudget].id,
    [BIPS.KlntBudget].klntnr,
    [BIPS.KlntBudget].wksnr,
    [BIPS.KlntBudget].boekjaar,
    [BIPS.KlntBudget].budget_euro,
    [BIPS.KlntBudget].budget_uren,
    [BIPS.KlntBudget].mwnr_budget,
    [BIPS.KlntBudget].startdatum,
    [BIPS.KlntBudget].isvpa,
    [BIPS.KlntBudget].mwnr_aanmaak,
    [BIPS.KlntBudget].mwnr_gewijzigd,
    [BIPS.KlntBudget].datum_gewijzigd,
    [BIPS.KlntBudget].reden_gewijzigd,
    [BIPS.KlntBudget].volgnummer

    Voor een klant wil ik per wksnr het hoogste volgnummer opvragen. En dan niet alleen het volgnummer, maar het volledige record. Combinatie van klntnr, wksnr, mwnr_budget en volgnummer zijn de PK.

  2. #2
    Geen idee of dit werkt maar...

    SQL Code:
    1. SELECT A.*
    2. FROM [BIPS.KlntBudget] A
    3. INNER JOIN (
    4.  SELECT klntnr, wksnr, max(volgnummer) AS max
    5.  FROM [BIPS.KlntBudget]
    6.  GROUP BY klntr, wknrs
    7. ) AS x ON A.klntnr=x.klntnr AND A.wksnr=x.wksnr AND A.volgnummer = x.max

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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