When I run this query I get:
SELECT DISTINCT r2.ApplicationBK,
max(r2.DatumApplication) maxdatum,
p.Name
FROM FCT_Recruitment r2,
DIM_WervingsProject wp,
DIM_Persoon p
WHERE r2.WervingsProjectID = wp.WervingsProjectID
AND r2.PersoonID=p.PersoonID
GROUP BY ApplicationBK,
p.name
The names are standing in TALBLE DIM_PERSOON P
The "ApplicationBK" are standing in DIM_Wervingsproject
and all the dates (DatumAppliocation) are standing in FCT_Recruitment
BK - Date - Name
012 20-03-1999 - name1
023 21-03-1999 - name1
033 22-03-1999 - name1
112 20-03-1990 - name2
123 20-03-1999 - name2
133 20-03-1990 - name2
But i need the highest date for each name.. So each name may only stand one time in the 'name-column' with the corresponding id (ApplicationBK) and date. I don't need to rest.
When this didn't work I tried something else...
SELECT WervingsprojectBK,
r.ApplicationBK,
p.Name,
count(*) number,upper(r.StatusWP) status,
upper(r.StatusApplication)statusdetail,
r.DateApplication
FROM FCT_Recruitment AS r,
DIM_WervingsProject wp,
DIM_Persoon p
INNER JOIN
(SELECT DISTINCT r2.ApplicationeBK,
max(r2.DateApplication) maxdatum
FROM FCT_Recruitment r2,
DIM_WervingsProject wp,
DIM_Persoon p
WHERE r2.WervingsProjectID=wp.WervingsProjectID
AND r2.PersoonID=p.PersoonID
GROUP BY ApplicationBK) AS r2 ON (r.ApplicationBK=r2.ApplicationBK
AND r.DateApplication=r2.maxdatum)
GROUP BY WervingsprojectBK,
r.ApplicationBK,
p.Naam,
r.StatusApplication,
r.StatusWP
ORDER BY 5
but then i get these errors..:
Msg 4104, Level 16, State 1, Line 3 The multi-part identifier "r.ApplicationBK" could not be bound. Msg 4104, Level 16, State 1, Line 3 The multi-part identifier "r.DateApplication" could not be bound.
Can you please help this newby.. Thanks.