select * from ATABLE_no a
where (select count(1) from ATABLE_no where N_CON<=a.N_CON)
between 2 and 3
解决方案 »
- delete * from 表名 为什么提示 invalid table name ?
- 列转行的问题
- 一个查询的存储过程,希望大家帮帮忙
- 再问inner join和left join
- 关于SQL7.0恢复SQL2000的备份的问题!
- 如何使U盘exe文件可以运行,但不能被拷贝?
- SQL2000 总是每天出现一两次自己停止,论坛上的有出现同类的我看了,没解决,急须求助
- 数据库中数据的回复
- 一个sql语句的问题?
- 只作INSERT和 UPDATE的同步,因为表太多不想使用对每个建立表触发器,SQL的复制功能也不能使用,有什么办法吗?
- 比如我在表A中删除一条记录后让表B的RS字段减1
- 大家看看这条语句哪里有毛病啊??
go
create table [ATABLE_no]([N_FNAME] varchar(10),[N_CON] int)
insert [ATABLE_no] select 'AF',1
union all select 'BF',10
union all select 'CF',20
union all select 'ANF',60
goselect *
from [ATABLE_no] t
where (
select count(1)
from [ATABLE_no]
where N_CON<=t.N_CON
) between 2 and 3
/*
N_FNAME N_CON
---------- -----------
BF 10
CF 20(2 行受影响)
*/
insert ATABLE_no select 'AF',1
union all select 'BF',10
union all select 'CF',20
union all select 'ANF',60
union all select 'BF',5
2.pt1314917 的语句:select * from ATABLE_no a
where (select count(1) from ATABLE_no where N_CON<=a.N_CON)
between 2 and 3/*
--结果:
N_FNAME N_CON
-----------------
BF 10
BF 5*/
那就改成>=
select * from ATABLE_no a
where (select count(1) from ATABLE_no where N_CON>=a.N_CON)
between 2 and 3
select * from ATABLE_no a
where (select count(distinct N_CON) from ATABLE_no where N_CON>=a.N_CON)
between 2 and 3