我有表说VendorReport在此表中,我有三列ID,PrefixId,在我的表Download_date 数据如下获取从唯一的记录表中的SQL Server最小的日期
ID PrefixId Download_date
1 VIS017 28-09-2012
2 VIS028 29-09-2012
3 VIS035 29-09-2012
4 VIS028 30-09-2012
5 VIS028 29-09-2012
6 VIS028 01-10-2012
7 VIS025 30-09-2012
我想要的如下所示,具有最小日期的独特PrefixId记录
1 VIS017 28-09-2012
2 VIS028 29-09-2012
3 VIS035 29-09-2012
4 VIS025 30-09-2012
所以我试过这个查询,但没有得到预期的结果。
select VendorReport.PrefixId,VendorReport.Download_Date from VendorReport
join (select PrefixId, MIN(Download_Date) d_date from VendorReport group by PrefixId) t2 on VendorReport.PrefixId= t2.PrefixId order by VendorReport.Download_Date asc