发布网友 发布时间:2022-04-10 03:46
共2个回答
懂视网 时间:2022-04-10 08:07
‘,‘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-04-10 05:15
DB2 V10.1 增加了很多新的特性和改进,很多用户由于业务系统的需要,希望将 DB2 从之前的老版本升级到 V10.1。本文以 DB2 V9.7 到 DB2 V10.1 的升级为例来讲解具体的升级过程。