发布网友 发布时间:2022-05-02 04:44
共4个回答
懂视网 时间:2022-05-02 09:05
‘,‘A类小型公司‘,3000000,NULL,‘AS‘); INSERT INTO OLIVER_MAP(ID,COM_TYPE,COM_NAME,SR_UP,SR_LIM,RES) VALUES(2,‘A2‘,‘A类小型公司‘,3000000,NULL,‘AS‘); INSERT INTO OLIVER_MAP(ID,COM_TYPE,COM_NAME,SR_UP,SR_LIM,RES) VALUES(3,‘B1‘,‘B类大型公司‘,100000000,NULL,‘BB‘); INSERT INTO OLIVER_MAP(ID,COM_TYPE,COM_NAME,SR_UP,SR_LIM,RES) VALUES(4,‘B2‘,‘B类大型公司‘,100000000,NULL,‘BB‘); INSERT INTO OLIVER_MAP(ID,COM_TYPE,COM_NAME,SR_UP,SR_LIM,RES) VALUES(5,NULL,null,null,NULL,‘O‘); 第二步:创建测试数据进行测试CREATE TABLE OLIVER_01(ID INT,COM_TYPE VARCHAR(100),SR DECIMAL(18,2),YQFL VARCHAR(10)); INSERT INTO OLIVER_01 VALUES(1,‘A1‘,30000000,‘O‘); INSERT INTO OLIVER_01 VALUES(2,‘A2‘,30000000,‘O‘); INSERT INTO OLIVER_01 VALUES(3,‘B1‘,100000000,‘BB‘); INSERT INTO OLIVER_01 VALUES(4,‘B2‘,100000000,‘BB‘); INSERT INTO OLIVER_01 VALUES(5,‘C‘,100000000,‘O‘); INSERT INTO OLIVER_01 VALUES(6,‘A1‘,NULL,‘O‘); INSERT INTO OLIVER_01 VALUES(7,‘A2‘,NULL,‘O‘); INSERT INTO OLIVER_01 VALUES(8,‘B1‘,NULL,‘O‘); INSERT INTO OLIVER_01 VALUES(9,‘B2‘,NULL,‘O‘); INSERT INTO OLIVER_01 VALUES(10,‘A1‘,30000001,‘O‘);
第三步骤:查询结果
SELECT T.* ,(SELECT RES FROM OLIVER_MAP A WHERE (A.COM_TYPE IS NULL OR A.COM_TYPE=T.COM_TYPE) AND (A.SR_UP IS NULL OR A.SR_UP>=T.SR) AND (A.SR_LIM IS NULL OR A.SR_LIM<T.SR) ORDER BY A.ID FETCH FIRST ROW ONLY) AS RES FROM OLIVER_01 T
OLIVER_01表数据
映射表数据
查询结构
该案例适用于存在映射表,然后根据映射表匹配得出结果!
【DB2】根据映射表映射出结果
标签:pre alt 映射 测试 表数据 arch res http style
热心网友 时间:2022-05-02 06:13
DB2中可以同远程编目的方式将另一个数据库挂载进来。热心网友 时间:2022-05-02 07:31
要访问远程数据库,必须先catalog,表级别的编目,貌似不支持的吧热心网友 时间:2022-05-02 09:06
我不用不知道诶