简单表:
create table [dbo].[payraisehistory]
(
[id][int] not null,
[payrate][money] not null,
[empid][int] not null
)
// 查询返回最后一次加薪
select prh.empid, max(prh.dategrant)
from payraisehistory prh
group by prh.empid
empid (No column name)
2 2013-07-30 00:00:00.000
3 2013-07-30 00:00:00.000
我怎样才能得到回报......
我想在不使用嵌套查询的情况下做到这一点。我在 group by 中缺少什么?
select prh.empid, prh.payrate, max(prh.dategrant)
from payraisehistory prh
group by prh.empid, payrate
empid payrate (No column name)
2 20.00 2013-04-30 00:00:00.000
2 30.00 2013-05-30 00:00:00.000
2 40.00 2013-06-30 00:00:00.000
2 50.00 2013-07-30 00:00:00.000
3 100.00 2013-04-30 00:00:00.000
3 120.00 2013-07-30 00:00:00.000