select Top 1 col1,max(col2) as maxN from table group by col1 order by max(col2) desc
GROUP BY 是几个字段的,而必须select出所有的字段出来
比如表Table 有 A,B,C,D四个字段 group by(A+B), max(C),D字段也要select出来
select a.* from TABLE a, (select FIELD1,MFIELD2=max(FIELD2) from TABLE group by FIELD1) b where a.FIELD1=b.FIELD1 and a.FIELD2=b.MFIELD2
select * from table group by name having (select max(field) from table)
select a.* from TABLE a, (select FIELD1,MFIELD2=max(FIELD2) from TABLE group by FIELD1) b where a.FIELD1=b.FIELD1 and a.FIELD2=b.MFIELD2 测试过,能用 在sybase ase中也能用吗?
from table
group by col1
order by max(col2) desc
group by(A+B), max(C),D字段也要select出来
(select FIELD1,MFIELD2=max(FIELD2) from TABLE group by FIELD1) b
where a.FIELD1=b.FIELD1 and a.FIELD2=b.MFIELD2
group by name
having (select max(field) from table)
(select FIELD1,MFIELD2=max(FIELD2) from TABLE group by FIELD1) b
where a.FIELD1=b.FIELD1 and a.FIELD2=b.MFIELD2
测试过,能用
在sybase ase中也能用吗?