| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 732 人关注过本帖
标题:查找相关两行数据
只看楼主 加入收藏
fdqzy
Rank: 1
等 级:新手上路
帖 子:368
专家分:0
注 册:2016-8-15
结帖率:73.97%
收藏
已结贴  问题点数:20 回复次数:2 
查找相关两行数据
如下表:
程序代码:
create cursor b1 (m1 n(3),m2 c(3))
insert into b1 values (4," ")
insert into b1 values (1,"A")
insert into b1 values (0,"A")
insert into b1 values (1," ")
insert into b1 values (3,"  ")
insert into b1 values (4,"")
insert into b1 values (2,"A")
insert into b1 values (6," ")
insert into b1 values (8," ")
insert into b1 values (2,"A")


查找m2含A,并筛选出此行和相关的上一行数据,得到如下数据:
程序代码:
create cursor b1 (m1 n(3),m2 c(3))
insert into b1 values (4," ")
insert into b1 values (1,"A")
insert into b1 values (0,"A")
insert into b1 values (4,"")
insert into b1 values (2,"A")
insert into b1 values (8," ")
insert into b1 values (2,"A")

[/color]
应如何进行?谢谢!

[此贴子已经被作者于2021-8-13 18:41编辑过]

搜索更多相关主题的帖子: insert values 行数 into 查找 
2021-08-13 18:35
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9841
专家分:27213
注 册:2012-2-5
收藏
得分:20 
程序代码:
create cursor b1 (m1 n(3),m2 c(3))
insert into b1 values (4," ")
insert into b1 values (1,"A")
insert into b1 values (0,"A")
insert into b1 values (1," ")
insert into b1 values (3,"  ")
insert into b1 values (4,"")
insert into b1 values (2,"A")
insert into b1 values (6," ")
insert into b1 values (8," ")
insert into b1 values (2,"A")

create cursor b2 (m1 n(3),m2 c(3))
SELECT * FROM b1 INTO ARRAY lb
FOR lnj = 1 TO ALEN(lb, 1)
    IF lnj < ALEN(lb, 1) AND "A" $ lb[lnj + 1, 2]
        INSERT INTO b2 VALUES (lb[lnj, 1], lb[lnj, 2])
        IF lb[lnj, 2] != lb[lnj + 1, 2]
            INSERT INTO b2 VALUES (lb[lnj + 1, 1], lb[lnj + 1, 2])
        ENDIF 
    ENDIF 
ENDFOR
SELECT b2
BROWSE 

坚守VFP最后的阵地
2021-08-13 19:44
fdqzy
Rank: 1
等 级:新手上路
帖 子:368
专家分:0
注 册:2016-8-15
收藏
得分:0 
回复 2楼 sdta
谢谢!
2021-08-13 20:36
快速回复:查找相关两行数据
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021325 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved