I think I have a solution, if I understand correctly. I'll set up a set of sample data, which I will then query. I'm using the Query Analyzer in SQL Server Management Studio for running the code in the sample.
First, I'll set up a table:
CREATE TABLE clienttable
(
client VARCHAR(25),
producer VARCHAR(25),
submitdate INT
);
Then, I'll populate the table with fictitious data:
INSERT INTO clienttable
VALUES
('Ceres','Zeus',20100115),
('Hespera','Athena',20100221),
('Ceres','Zeus',20100102),
('Juno','Poseiden',20100105),
('Jupiter','Apollo',20100316),
('Minerva','Hestia',20100225),
('Hespera','Athena',20100325),
('Nemesis','Vesta',20100310),
('Neptune','Hera',20100111),
('Neptune','Hestia',20100212),
('Jupiter','Apollo',20100320),
('Hespera','Athena',20100226);
I need to get a subset of the data from this table based on the first time a client is entered. To get that client entry record, I run this query:
SELECT
client,
MIN(submitdate) AS firstPolicy
FROM clienttable
GROUP BY client;
And I get 7 rows:
client firstPolicy
------------------------- -----------
Ceres 20100102
Hespera 20100221
Juno 20100105
Jupiter 20100316
Minerva 20100225
Nemesis 20100310
Neptune 20100111
Then, I use this query to join against the actual table in order to get the producer - I'm joining a subset of the table to the table itself:
SELECT
T2.client,
T2.firstPolicy,
T1.producer
FROM clienttable T1
INNER JOIN
(
SELECT
client,
MIN(submitdate) AS firstPolicy
FROM clienttable
GROUP BY client
) AS T2
ON T1.client = T2.client
AND T1.submitdate = T2.firstPolicy;
And this give me this result:
client firstPolicy producer
------------------------- ----------- -------------------------
Ceres 20100102 Zeus
Hespera 20100221 Athena
Juno 20100105 Poseiden
Jupiter 20100316 Apollo
Minerva 20100225 Hestia
Nemesis 20100310 Vesta
Neptune 20100111 Hera
Is this what you're looking for?