如何在数据库或数据窗口中提取指定求和值的记录
各位高手,
我想在数据库或数据窗口中过滤指定求和值的记录,不如有如下记录:
ID VALUE
1 25
2 43
3 44
4 56
... ...
比如我想将VALUE求和值等于69的记录,也就是ID为1和3的记录提取出来.该如何实现,如何编程,请帮忙,谢谢!
[解决办法]
求和,是几个ID的和,2个,3个....
[解决办法]
数据窗口不好实现,用SQL吧,
if not exists(select 1 from sysobjects where name='tb_xx')
CREATE TABLE TB_XX(
ID numeric(10,0) not null primary key,
value numeric(10,2) not null default 0
)
GO
insert into tb_xx(id,value)
select 1,25
union
select 2,43
union
select 3,44
union
select 4,56
GO
select * from (
select a.id,a.value,xx=(select id from tb_xx where id>a.id and value+a.value=69) from tb_xx a) aaa where xx is not null
go
[解决办法]