create table #TestTable ( PatientName varchar(132), ApptNumber int, ApptDate datetime);insert into #TestTablevalues('John Smith',18374832,'2012-01-05 08:15:00'),('John Smith',19837289,'2012-01-07 14:30:00'),('John Smith',19982776,'2012-02-15 09:00:00'),('John Smith',20091092,'2012-02-27 15:45:00'),('John Smith',20100939,'2012-02-28 07:25:00'),('John Smith',20110938,'2012-03-05 16:50:00');with BaseData as (select PatientName, ApptNumber, ApptDate, rn = row_number() over (partition by PatientName, dateadd(mm, datediff(mm, 0, ApptDate), 0) order by ApptDate asc)from #TestTable)select PatientName, ApptNumber, ApptDatefrom BaseDatawhere rn = 1;drop table #TestTable;/*Given that data the query will only return:John Smith 18374832 2012-01-05 08:15:00John Smith 19982776 2012-02-15 09:00:00John Smith 20110938 2012-03-05 16:50:00*/