Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 486275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:29:12+00:00 2026-05-13T01:29:12+00:00

I thought I had it but it seemed I was wrong. I have a

  • 0

I thought I had it but it seemed I was wrong.

I have a query

select PrestatieCode, Uitvoerdatum, Identificatie, Foutmelding 
from bam_Zending_AllInstances as zAll
left outer join bam_Zending_CompletedRelationships as zRel on 
zAll.ActivityID = zRel.ActivityID
left outer join bam_Prestatie_AllInstances as pAll on 
zRel.ReferenceData = pAll.ActivityID
where zAll.Zender = 'BL15' 
and ReferenceType = 'Activity' 
and Zendingnummer = '632'

This shows a list of PrestatieCodes, also duplicates.
Now I only need to have a list of PretatieCodes without the duplicates, it should just pick the one with the lastest date. The datecolumn = Uitvoerdatum.

I thought I’d try something like:

select max(Uitvoerdatum), PrestatieCode  
from bam_Zending_AllInstances as zAll
left outer join bam_Zending_CompletedRelationships as zRel on 
zAll.ActivityID = zRel.ActivityID
left outer join bam_Prestatie_AllInstances as pAll on 
zRel.ReferenceData = pAll.ActivityID
where zAll.Zender = 'BL15' 
and ReferenceType = 'Activity' 
and Zendingnummer = '632'
group by PrestatieCode

which gives me what I want. However as you can notice it does not have the 2 columns “Identificatie” and Foutmelding. If I add these it gives me the error

Column 'bam_Prestatie_AllInstances.Identificatie' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

So I’m guessing my approach is wrong. I need to see all the columns but only for the latest “PrestatieCode”s.

Am I making any sense?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:29:13+00:00Added an answer on May 13, 2026 at 1:29 am

    Without any schema it is a tad difficult. But what you need to try is getting the id and max value (so in your case PrestatieCode and MAX(Uitvoerdatum) and then do a sub join)

    SELECT  YourTabel.*
    FROM    YourTabel INNER JOIN
            (
                SELECT  PrestatieCode,
                        MAX(Uitvoerdatum) MaxDates
                FROM    YourTabel
                WHERE   YourCondition
                GROUP BY PrestatieCode 
            ) YourTableMaxDates ON  YourTabel.PrestatieCode = YourTableMaxDates.PrestatieCode
                                AND YourTabel.Uitvoerdatum = YourTableMaxDates.MaxDates
    

    This should get you the latest data per PrestatieCode

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i thought i had solved this but my basic example seems to not be
I recently exported/imported an SP2010 site collection from Dev to Prod. The site collection
I have used Flex for about a year before deciding that I would rather
I inherited a data-storage which was using simple text-files to save documents. Documents had
I have created a multi-threaded application that runs fine on every system except for
Lets say you have a relational DB table like INVENTORY_ITEM. It's generic in the
The Context At the moment, I have a JTextArea that has been created like
I accidentally pushed some changes to the main branch which weren't ready, so I
As an alternately to my real question: does anyone know of a simple command
I'm trying to get my Django based webapp into a working deployment configuration, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.