select dt,max(sign) from a
group by month(dt)
group by month(dt)
解决方案 »
- sql server 2000与access数据之间的快速导入问题,请各位高手指点,在线等,急,急,,急,,,
- 数据更新操作
- 数据库事务控制的实现位置:服务器VS客户端,请大家讨论
- 讨论: 对于一个SQL语句,where后面的条件越多,那么查询速度会怎么样?
- 1亿条记录,select一下,可以吗?
- SQL 2000远程数据库服务器连接
- SQL Server为何提示“未找到提供者,可能未被正确安装”
- SqlServer2005,自动产生无数trc文件,如何停止?
- 急!在线请教
- 关于SQL2005无法附加SQL2008数据库的问题
- msde和sqlserver的效率应该是一样的吧?
- 如何导出sql server用户名密码
group by month(dt)
from T1 A
where not exists(select 1 from T1 where left(dt,7)=left(A.dt,7) and sign>A.sign)
a.*
from
t1 a
where
not exists(select
1
from
t1
where
convert(char(7),dt,120)=convert(char(7),a.dt,120)
and
sign>a.sign)
Inner Join (Select Month(dt) As dt,Max([sign]) As [sign] from T1 Group By Month(dt)) B
On Month(A.dt)=B.dt And A.[sign]=B.[sign]
create table T1
(
dt varchar(10),
sign int
)
insert T1
select '2005-07-01',1 union
select '2005-07-12',2 union
select '2005-08-01',1 union
select '2005-08-11',3--测试
select *
from T1 A
where not exists(select 1 from T1 where left(dt,7)=left(A.dt,7) and sign>A.sign)--删除测试环境
drop table T1--结果
/*
dt sign
---------- -----------
2005-07-12 2
2005-08-11 3
*/
create table T1
(
dt varchar(10),
sign int
)
insert T1
select '2005-07-01',1 union
select '2005-07-12',2 union
select '2005-08-01',1 union
select '2005-08-11',3--测试
select distinct a.* from T1 a left join T1 b
on year(a.dt)=year(b.dt) and month(a.dt)=month(b.dt) and a.sign<b.sign
where b.dt is null--删除测试环境
drop table T1
(所影响的行数为 4 行)dt sign
---------- -----------
2005-07-12 2
2005-08-11 3(所影响的行数为 2 行)
group by month(dt)
可能是你提交时出错(但系统已记录),你又重新提交了一交吧!