如有下表:
姓名 年度 工资 张三 1990 300
张三 1991 400
张三 1992 600
张三 1995 550
李四 1992 500
李四 1993 800
李四 1994 750
王某 1993 700
王某 1995 800要得出这样的结果:某人最大年度的工资额。
张三 1995 550
李四 1994 750
王某 1995 800
姓名 年度 工资 张三 1990 300
张三 1991 400
张三 1992 600
张三 1995 550
李四 1992 500
李四 1993 800
李四 1994 750
王某 1993 700
王某 1995 800要得出这样的结果:某人最大年度的工资额。
张三 1995 550
李四 1994 750
王某 1995 800
FROM 表名
table a,
(select 姓名,max(工资) from table group by 姓名) b
where a.姓名 = b.姓名 and a.工资 = b.工资
select top 1 a.* from
table a,
(select 姓名,max(工资) from table group by 姓名) b
where a.姓名 = b.姓名 and a.工资 = b.工资
group by a.姓名
order by 年度
table a,
(select 姓名,max(年度) from table group by 姓名) b
where a.姓名 = b.姓名 and a.年度 = b.年度
table a,
(select 姓名,max(年度) as 年度1 from table group by 姓名) b
where a.姓名 = b.姓名 and a.年度 = b.年度1asscess下测试过的。