重复记录的问题
怎么查询一个表里多个字段相同,只取某个字段最大值的那一条记录呢?
a  b  c  d  e  f  g  
1  2  3  4  5  6  7
1  2   3  4  5  6  8
取第二条
表无主键
              
------解决方案-------------------- 能确定哪个字段吗
------解决方案-------------------- --select max(a),max(b),max(c),max(d),max(e),max(f),max(g) from a
 
--就上面数据而言 
select a,b,c,d,e,f,max(g)g from [表名] 
group by a,b,c,d,e,f 
------解决方案-------------------- 我的博客里面有,你进去看看
------解决方案-------------------- 引用: --select max(a),max(b),max(c),max(d),max(e),max(f),max(g) from a 
 
--就上面数据而言 
select a,b,c,d,e,f,max(g)g from [表名] 
group by a,b,c,d,e,f 
  
思路很开阔啊。
------解决方案-------------------- select a.* from ( 
select a,b,c,d,e,f,max(g)g from [表名] 
group by a,b,c,d,e,f ) a inner join [表名] b 
where a.a=b.a and a.b=b.b and a.c=b.c and a.d=b.d and a.e=b.e and a.f=b.f 
 ------解决方案-------------------- 引用: select a.* from ( 
select a,b,c,d,e,f,max(g)g from [表名] 
group by a,b,c,d,e,f ) a inner join [表名] b 
where a.a=b.a and a.b=b.b and a.c=b.c and a.d=b.d and a.e=b.e and a.f=b.f