输入集,
CMP BND_CD STARTDATE ENDDATE
01 UF 03/15/2010 07/01/2010
01 TRL 03/15/2010 12/15/2014
虚拟数据
CREATE TABLE DATA ( CMP, BND_CD, STARTDATE, ENDDATE ) AS
SELECT '01','UF', DATE '2010-03-15', DATE '2010-07-01' FROM DUAL UNION ALL
SELECT '01','TRL', DATE '2010-03-15', DATE '2010-12-15' FROM DUAL;
我需要将输出作为3条记录,分割TRL / UF记录,即
CMP BND_CD STARTDATE ENDDATE
01 UF 03/15/2010 07/01/2010
01 TRL 03/15/2010 07/01/2010
01 TRL 07/01/2010 12/15/2014
如果日期范围相互重叠,则应对两个BND_CD的每个CMP代码进行拆分。我们必须根据CMP值对记录进行分组,然后如果TRL与UF重叠,则应拆分TRL reords,或者如果UFoverlaps TRL,UF记录应该被拆分。
答案 0 :(得分:1)
<强>查询强>:
id cd_used
1 trlupf
2 upfonly
3 trlonly
<强>输出强>:
client.publish('s/us/mqttjs_8303dec3','210,' +Math.random() *10)