求SQL 語句,该如何解决

求SQL 語句表: Yearint,Monthint,GIDint,Priceint年,月,商品,采購價格求全部商品,最後一次采購的價格。[解

求SQL 語句
表: 
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]
)
)