Thanks Alan but that doesn't really work for me.
Because what I want is to get for each part number the last (max date_a) percent_b that was entered
And the earliest date where is the subsequent percent_b.
INSERT @yourtable VALUES
('08477','A3689','2000-09-08 00:00:00.000','27418.7','A100'),
('08477','A3689','2000-09-09 00:00:00.000','27418.4','A100'),
('08477','A3689','2000-09-10 00:00:00.000','27418.2','A100'),
('08477','A3689','2001-05-01 00:00:00.000','27973.38','A69'),
('08477','A3689','2002-05-01 00:00:00.000','28818','A69'),
('08477','A3689','2003-05-01 00:00:00.000','30179.48','A69'),
('08477','A3689','2003-10-17 00:00:00.000','37833.7','A86'),
('08477','A3689','2004-05-01 00:00:00.000','38971.55','A86'),
('08477','A3689','2005-05-01 00:00:00.000','40235.84','A86'),
('08477','A3689','2006-05-01 00:00:00.000','41436.91','A86');
('08477','A3689','2004-05-02 00:00:00.000','38971.57','A100'),
('08477','A3689','2005-05-03 00:00:00.000','40235.87','A100'),
('08477','A3689','2006-05-04 00:00:00.000','41436.97','A100');
('08477','A3699','2003-10-17 00:00:00.000','37833.7','A86'),
('08477','A3699','2004-05-01 00:00:00.000','38971.55','A86'),
('08477','A3699','2005-05-01 00:00:00.000','40235.84','A86'),
('08477','A3699','2006-05-01 00:00:00.000','41436.91','A86');
('08477','A3699','2007-05-12 00:00:00.000','38971.57','A101'),
('08477','A3699','2008-05-13 00:00:00.000','40235.87','A101'),
('08477','A3699','2009-05-14 00:00:00.000','41436.97','A101');
For instance in the example above I would get
1 - part = A3689 and percent_b = 'A100' and the earliest date for that group = '2004-05-02 00:00:00.000'
2 - part = A3699 and percent_b = 'A101' and the earliest date for that group = '2007-05-12 00:00:00.000'
We want that earliest date because we want to know since when we start using that percentage
Let me know if that is clear now,
thanks