我在ACCESS中有这样一个表:期号 类型 收入我现在要实现这样一种功能:我需要得到类型属于"预支"的下一期的数据,我现在只会得到属于"预支"的期号。strsql := 'select 期号 from 数据表 where 类型="预支";如果没有这样的语句,莫非我要用下面的办法实现?1、strsql := 'select 期号 from 数据表 where 类型="预支";2、在取得属于"预支"的所有期数后,低效率地利用循环从数据库中取出 期号+1 的数据
解决方案 »
- delphi7的控件可不可以导入到delphi xe3里面来,让项目可以继续使用
- 想从delphi5转delphi7,大家谈谈各自有什么优、缺点。灌水有分!
- 用JAVA做一个网上象棋对战,要学JAVA的来共同探讨!
- 什么时候能散200分 先散100吧 顺便问个问题
- 开心,放分。真的真的很幸运阿。难道我就是传说中的超级无敌幸运星???
- 怎么取得当前运行程序的路径?
- 如何截获某个指定端口所有的Tcp包,和Udp包并显示其内容!!!
- delphi5环境中哪项设置可使跟踪进进程的时候,form隐去?
- 如何在MDI主窗体中访问由DLL创建的MDI子窗体?
- TTS中遇到的问题
- 一直挺困惑的错误? IdHttp.Get Exception class EIdHTTPProtocolException with message ''.
- 急,双网卡设置路由的问题,在线等
where current.类型="预支" and (Current.期号+1) = Next.期号
(基本上没用过Access,试试看行不)
from table1
where 类型='预支' and 期号 not in
(select top 1 期号 from table1 where 类型='预支' )
order by 类型
where 类型='预支'
and exists(select 1 from # where 类型=a.类型 and id<a.id)--id 为种子数
create table #
(期号 varchar(5), 类型 varchar(10), 收入 tinyint)
insert into #
select '001', '暂欠', 100 union all
select '002', '预支', 111 union all
select '003', '扣除', 122 union all
select '004', '扣除', 133 union all
select '005', '预支', 144 union all
select '006', '暂欠', 155 union all
select '007', '暂欠', 166 union all
select '008', '预支', 177 union all
select '009', '暂欠', 188
select a.* from # a,(select * from # where 类型='预支')b
where a.期号=b.期号+1/*
期号 类型 收入
----- ---------- ----
003 扣除 122
006 暂欠 155
009 暂欠 188(所影响的行数为 3 行)
*/
我的“数据表”数据量较大啊是不是要将“数据表”复制到表a中?
谢谢了,我是菜鸟。