select 国家
       ,物品
       ,convert(char(10),日期,120)
from 表
group by  国家
          ,物品
          ,convert(char(10),日期,120)

解决方案 »

  1.   

    --是要这个效果吗?
    declare @t table(国家 varchar(20),物品 varchar(20),日期 datetime)
    insert into @t select '中国','面包','2004-9-1 12:01'
    union all select '中国','面包','2004-9-2 11:23'
    union all select '中国','面包','2004-9-2 13:16'
    union all select '中国','鸡蛋','2004-9-1 09:12'
    union all select '美国','纸张','2004-9-1 12:12'
    --查询
    select 国家,物品,
    日期=max(日期) --min也可以
      from @t a
    group by 国家,物品,convert(varchar(10),日期,120)
    --结果
    国家          物品             日期                                                    
    --------------------  ----------------------
    美国           纸张                   2004-09-01 12:12:00.000
    中国           鸡蛋                   2004-09-01 09:12:00.000
    中国           面包                   2004-09-01 12:01:00.000
    中国           面包                   2004-09-02 13:16:00.000(所影响的行数为 4 行)