select aa,bb,max(cc),dd,ee
from table
where aa = @aa
group by aa,bb,dd,ee;
from table
where aa = @aa
group by aa,bb,dd,ee;
解决方案 »
- 如何统计问题出现的次数》》如何统计问题出现的次数
- 如何用sql语句列出 两记录相加等于90的所有数据呢?
- 帮忙写一条触发器语句(因为急用)
- 向一个表插入数据,将部分数据插入另一个表
- 求一分页解决方案, 不能 用存储过程
- SQL server 2008R2中如何直接修改表内数据?
- 我想做个考勤表,各位大哥给我点建议!
- 关于数据库交并关系的问题~~~请高手速来帮忙
- 跪求答案!!!!!!!!!!!!!!!!!!!!!!!!!
- 末尾加了个where条件,查询时间有0.00S秒降至14S,请教各位,什么原因,谢谢!
- 很低级的问题,读取记录问题?
- 如何将SQL Server 6.5装在一台没有连接网线的笔记本电脑上
from table
where aa = @aa
group by aa,bb
或: select @aa aa,bb,max(cc),dd,ee
from table
where aa = @aa
group by bb
join
(Select bb,max(cc) as cc from table group by bb) b
on a.bb = b.bb and a.cc = b.cc
where a.aa = @aa
select @aa aa,bb,max(cc),max(dd),max(ee)
from table
where aa = @aa
group by bb
select aa,bb,max(cc),dd,ee
from table
where aa = @aa
group by bb,aa,dd,ee
from table
where aa = @aa
group by aa,bb,dd,ee或:
select max(aa),max(bb),max(cc),max(dd),max(ee )
from table
where aa = @aa
group by bb
form table
where aa=@aa and cc=max(cc)
group by aa,bb,cc,dd,ee;
create table aiii (aa int,bb int,cc int,dd int,ee int)
insert into aiii select 1,1,1,1,1
insert into aiii select 1,1,3,1,1
insert into aiii select 2,1,2,1,1
insert into aiii select 3,1,3,1,1
insert into aiii select 4,1,4,1,1
insert into aiii select 4,1,1,1,1
go
select aa,bb,cc,dd,ee from aiii as a
where cc=(select max(cc) from aiii as b where b.aa=a.aa)
order by aa
select a.*
from aiii as a join (select aa,max(cc) as cc from aiii group by aa) as b
on a.aa=b.aa and a.cc=b.cc
order by a.aa