Hello!
I have a question and I don’t know whether the title is actually descriptive.
For some background on the matter, we use Sage 50 as our merchandise information system and for our reporting and controlling tools we run Access queries. Since our database had been reset at some point I am missing some history data. I need to find the creation date for each article. But the only query covering the whole period since the beginning will return a table like that:
PK | ART | DATE
3262 | 000 | 17.05.2013
3262 | 000 | 23.01.2019
3150 | 0003 | 03.06.2013
3150 | 0003 | 23.01.2018
3150 | 0003 | 43.05.2019
(where PK
is the article’s primary key, ART
its article number and DATE
the date of the last update)
The query looks like this:
SELECT *
FROM (SELECT sg_auf_artikel_history.SG_AUF_ARTIKEL_PK AS PK, sg_auf_artikel.ARTNR AS ART, sg_auf_artikel_history.AKTDAT AS DAT
FROM sg_auf_artikel_history INNER JOIN sg_auf_artikel ON sg_auf_artikel_history.SG_AUF_ARTIKEL_PK = sg_auf_artikel.SG_AUF_ARTIKEL_PK
GROUP BY sg_auf_artikel_history.SG_AUF_ARTIKEL_PK, sg_auf_artikel.ARTNR, sg_auf_artikel_history.AKTDAT)
ORDER BY ART, DAT;
How can I get the following result:
PK | ART | DATE
3262 | 000 | 17.05.2013
3150 | 0003 | 03.06.2013
That is, I only want for each article the oldest entry.
I’d appreciate your solutions!
Thanks in advance!
Holger