求助::
一张表有三个字段, 分别为Id(Primary key), number(库存数量) amount(总金额),一般情况下, number的值变化不会太大的, 上下浮动不超过2, 但是有几天这个number的变化特别大 要求查询出这几条数据, 怎么下手?
一张表有三个字段, 分别为Id(Primary key), number(库存数量) amount(总金额),一般情况下, number的值变化不会太大的, 上下浮动不超过2, 但是有几天这个number的变化特别大 要求查询出这几条数据, 怎么下手?
解决方案 »
- 一个Oracle问题
- SQL%COUNT的问题
- 在存储过程中能不能调用web服务?
- oracle如何判断2个日期之间相隔天数的问题
- 疑是 Oracle 10g 乘法Bug
- 我在ASP中用ODBC连接ORACLE,表中有CLOB类型,只要是SELECT CLOB型数据,就出现如下错误,高手请进
- 关于 oracle 8 中的 left outer join
- 菜问题:我怎么在dba stadio里找不到外键FK在哪里啊??请问在树状结构里有么,请告之
- 到底什么是序列,怎么用呢?
- 如何拓展数据库空间
- ADO访问oracle存储过程返回结果集在调用_CommandPtr的Execute函数时报异常
- 存储过程是怎么运行的
最大的number就显示在前面了
number值的变化是通过update来控制还是直接插入的
CREATE TABLE `testtable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`number` int(11) NOT NULL,
`amount` float NOT NULL,
PRIMARY KEY (`id`)
)INSERT INTO `testtable` VALUES ('1', '10', '1000');
INSERT INTO `testtable` VALUES ('2', '11', '12000');
INSERT INTO `testtable` VALUES ('3', '9', '9000');
INSERT INTO `testtable` VALUES ('4', '12', '13000');
INSERT INTO `testtable` VALUES ('5', '13', '12444');
INSERT INTO `testtable` VALUES ('6', '2', '12000');
INSERT INTO `testtable` VALUES ('7', '100', '1231238');
where abs(a.number- b.number) > 10 --是你认为浮动多大算大的一个数,这里认为相差10算浮动大
and a.id = b.id - 1
union
select b.id, b.numberfrom testtable a, testtable b
where abs(a.number- b.number) > 10
and a.id = b.id - 1
(
select 1 ID, 2 NC from dual union all
select 1 ID, 9 NC from dual union all
select 1 ID, 7 NC from dual union all
select 1 ID, 13 NC from dual union all
select 1 ID, 8 NC from dual union all
select 1 ID, 5 NC from dual union all
select 1 ID, 3 NC from dual union all
select 1 ID, 12 NC from dual union all
select 1 ID, 10 NC from dual union all
select 1 ID, 11 NC from dual
)
select * from T,(select avg(nc) AVG_ALL from T) A where ABS(nc - A.AVG_ALL) > 2;