表:
Year int ,Month int, GID int, Price int
年,月,商品,采購價格
求全部商品,最後一次采購的價格。
------解决方案--------------------
表:
Year int ,Month int, GID int, Price int
select * from 表 a
where not exists (
select 1 from 表
where GID=a.GID
and ([Year]> a.[Year]
or [Year]=a.[Year]
and [Month]> a.[Month]
)
)