首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求一语句

2012-06-15 
【求助】求一语句SQL codetest_item_namepointer_condition_textpointer_condition_text2aa1b5b cd998

【求助】求一语句

SQL code
test_item_name  pointer_condition_text  pointer_condition_text2a                                               a<1;b<=5  b c        d                   <998        


想要的结果为
SQL code
test_item_nameacd


解释:取pointer_condition_text不为空,
或者pointer_condition_text为空,但是pointer_condition_text2中不包含text_item_name的数据。


[解决办法]
SQL code
with t1 as(     select 'a' c1,null c2,'a<1;b<=5' c3 from dual     union all     select 'b' c1,null c2,null c3 from dual     union all     select 'c' c1,null c2,null c3 from dual     union all     select 'd' c1,'<998' c2,null c3 from dual)select distinct c1from t1,(     select replace(regexp_substr(c3,'[^;]+',1,level),';',' ') val     from t1      connect by level<=length(c3)-length(replace(c3,';',''))+1) t2 where length(replace(val,c1,'')) < length(val) or c2 is not nullorder by c1     c1----------------1    a2    b3    d 

热点排行