Hello, I have the following code with the following results:
CODE
Select a.bladnummer, a.naam, max(a.datum), a.datumid from
(SELECT tekeningen.bladnummer, tekeningen.naam, max(datums.datum) as Datum, datums.datumid from tekeningen
inner join datums on tekeningen.tekeningid=datums.tekeningid where tekeningen.bedrijvenid=102
group by tekeningen.bladnummer,tekeningen.naam, datums.datumid) a
group by a.bladnummer, a.naam, a.datumid
order by a.bladnummer
Bladnummer Naam Datum DatumID
1 K1 Palenplan 2008-02-29 232
2 K1 Palenplan 2008-03-07 241
3 K2 Beganegrond 2008-02-29 233
4 K2 Beganegrond 2008-03-07 240
5 K3 1e verdvloer 2008-02-29 234
6 K4 2e verdvloer 2008-02-29 235
7 K5 3e verdvloer 2008-02-29 236
8 K6 Dakvloer 2008-02-29 237
As you can see all dates in the column "Datum" are 2008-02-29 except two. These other two are with the date 2008-03-07.
I selected on max(date) but because these two dates have another value in the column "DatumID" it also shows the lower date.
My selectquery must only show the latest dates, so the value from row 1 and 3 i don't wan't to get shown!
I believe this must be easy, but i don't now how!!
Please help!