基本上我想为数据集中的每个[typecode]提取最高[生效日期] ...
HIC CODE PROVIDER DATE TYPECODE EFFECTIVE DATE
028207696D 10 347330 2014-09-15 00:00:00.000 0 2014-10-10 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 0 2015-01-30 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 1 2015-01-23 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 1 2015-02-06 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 2 2015-02-06 00:00:00.000
看起来像这样:
HIC CODE PROVIDER DATE TYPECODE EFFECTIVE DATE
028207696D 10 347330 2014-09-15 00:00:00.000 0 2015-01-30 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 1 2015-02-06 00:00:00.000
028207696D 10 347330 2014-09-15 00:00:00.000 2 2015-02-06 00:00:00.000
答案 0 :(得分:1)
SELECT HIC,CODE,PROVIDER DATE,TypeCode,MAX([Effective Date])[Effective Date]
FROM <TABLE>
GROUP BY HIC,CODE,PROVIDER DATE,TypeCode