Sql regexp_substr结果的distinct和order by

Sql regexp_substr结果的distinct和order by,sql,oracle,distinct,clob,Sql,Oracle,Distinct,Clob,我得到了一个sql,它给了我预期的结果: select regexp_substr(longarg, '30G([^|]*)', 1, 1, '', 1) founded from dod; 如果我试图区分我的结果 select distinct regexp_substr(longarg, '30G([^|]*)', 1, 1, '', 1) founded from dod; 我得到的信息是: ORA-00932: 00932. 00000 - "inconsistent dataty

我得到了一个sql,它给了我预期的结果:

select regexp_substr(longarg, '30G([^|]*)', 1, 1, '', 1) founded from dod;
如果我试图区分我的结果

select distinct regexp_substr(longarg, '30G([^|]*)', 1, 1, '', 1) founded from dod;
我得到的信息是:

ORA-00932: 00932. 00000 -  "inconsistent datatypes: expected - got CLOB"
另一个问题是。如何使用排序依据对结果集进行排序? 正如你所看到的,我并不是一个真正的oracle sql专家

谢谢你的帮助


Stefan

看起来您的列是CLOB,不幸的是,您遇到了一些限制(不能在DISTINCT或ORDER BY等中使用它们。有关完整列表,请参阅:)

但是,如果从regexp_substr返回的内容少于4000个字符,则可以使用to_char(),这将允许您通过以下方式按不同/顺序使用它:

select distinct to_char(regexp_substr(longarg, '30G([^|]*)', 1, 1, '', 1)) founded
from dod
order by founded;