SQL语句提示缺失右括号,求高人解答

select*from(selectrownumRN,t.*from(SELECTT1.meta_id,T1.ext_attr1,T1.ext_attr36,T1.ext... select * from
(select rownum RN, t.* from
(
SELECT T1.meta_id,T1.ext_attr1,T1.ext_attr36,T1.ext_attr39,
substr(ltrim (T1.path,'C00/') ,1,instr(ltrim (T1.path,'C00/') ||'/','/',1,1)-1) as ext_attr37,
case when (substr(ltrim (T1.path,'C00/') ,instr(ltrim (T1.path,'C00/') ||'/','/',1,1)+1,instr(ltrim (T1.path,'C00/') ||'/','/',1,2)-instr(ltrim (T1.path,'C00/') ||'/','/',1,1)-1)) is null then '/' else substr(ltrim (T1.path,'C00/') ,instr(ltrim (T1.path,'C00/') ||'/','/',1,1)+1,instr(ltrim (T1.path,'C00/') ||'/','/',1,2)-instr(ltrim (T1.path,'C00/') ||'/','/',1,1)-1) end as ext_attr38,
T1.meta_cn_name,T1.meta_en_name,T1.note,T1.ext_attr2, T1.ext_attr3, T1.ext_attr4, T1.ext_attr5,
T1.ext_attr6, T1.ext_attr7, T1.ext_attr8, T1.ext_attr9, T1.ext_attr10, T1.ext_attr11,
T1.ext_attr12, T1.ext_attr13, T1.input_staff_id, T1.check_ind, T1.check_dttm, T1.check_staff_id, T1.check_out_ind,
T1.check_out_dttm, T1.check_out_staff_id, T1.end_dttm, T1.ver_id, T1.path, T1.doc_id
from am_meta_entity_info T1
where 1=1 and T1.inst_cate_cd in('C07100') and to_Date(T1.START_DTTM,'yyyy-mm-dd') >= to_date('2015-06-01','yyyy-mm-dd') and to_Date(T1.START_DTTM,'yyyy-mm-dd') <= to_date('2015-06-23','yyyy-mm-dd'))) and T1.check_ind ='Y'
and T1.oper_type!='3'
and T1.end_dttm like '2999-12-31 00:00:00%'
order by ext_attr1
) t where rownum < 21 ) where RN > 0
错误出现的地点是“ and T1.check_ind ='Y'”这句的and上
展开
 我来答
tim_spac
2015-06-08 · TA获得超过3628个赞
知道大有可为答主
回答量:1804
采纳率:100%
帮助的人:2006万
展开全部

try this:

/* replace next sql script's context:
LPOS1 ==> instr(ltrim(T1.path,'C00/') ||'/','/',1,1)
LPOS2 ==> instr(ltrim(T1.path,'C00/') ||'/','/',1,2)
*/

select * from (
    select rownum RN, t.*
    from (
        SELECT T1.meta_id
            ,T1.ext_attr1
            ,T1.ext_attr36
            ,T1.ext_attr39
            ,substr(
                ltrim(T1.path,'C00/'),
                1,
                LPOS1-1
                ) as ext_attr37
            ,case when substr(
                            ltrim(T1.path,'C00/'),
                            LPOS1+1,
                            LPOS2-LPOS1-1
                            ) is null
                  then '/'
             else substr(
                        ltrim(T1.path,'C00/'),
                        LPOS1+1,
                        LPOS2-LPOS1-1)
             end as ext_attr38
            ,T1.meta_cn_name
            ,T1.meta_en_name
            ,T1.note
            ,T1.ext_attr2
            ,T1.ext_attr3
            ,T1.ext_attr4
            ,T1.ext_attr5
            ,T1.ext_attr6
            ,T1.ext_attr7
            ,T1.ext_attr8
            ,T1.ext_attr9
            ,T1.ext_attr10
            ,T1.ext_attr11
            ,T1.ext_attr12
            ,T1.ext_attr13
            ,T1.input_staff_id
            ,T1.check_ind
            ,T1.check_dttm
            ,T1.check_staff_id
            ,T1.check_out_ind
            ,T1.check_out_dttm
            ,T1.check_out_staff_id
            ,T1.end_dttm
            ,T1.ver_id
            ,T1.path
            ,T1.doc_id 
        from am_meta_entity_info T1
        where 1=1
        and T1.inst_cate_cd in('C07100')
        and to_Date(T1.START_DTTM,'yyyy-mm-dd')
         >= to_date('2015-06-01','yyyy-mm-dd')
        and to_Date(T1.START_DTTM,'yyyy-mm-dd')
         <= to_date('2015-06-23','yyyy-mm-dd')
        and T1.check_ind ='Y'
        and T1.oper_type!='3'
        and T1.end_dttm like '2999-12-31 00:00:00%'
        order by ext_attr1
    ) t
    where rownum < 21
) where RN > 0
更多追问追答
追问

还是不对哦:

追答
T1.START_DTTM 是varchar or datetime?
datetime 字段的话试试看:
and T1.START_DTTM >= to_date('2015-06-01','yyyy-mm-dd')
and T1.START_DTTM <= to_date('2015-06-23','yyyy-mm-dd')
liguangwen91
2015-06-08 · TA获得超过131个赞
知道小有建树答主
回答量:239
采纳率:75%
帮助的人:50.6万
展开全部
这个:to_date('2015-06-23','yyyy-mm-dd'))) and T1.check_ind ='Y'

改为:to_date('2015-06-23','yyyy-mm-dd') and T1.check_ind ='Y'
追问
我改过来了,但是报“ORA-01830: 日期格式图片在转换整个输入字符串之前结束”
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式