select last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fxyg) over()-first_value(bj_fxyg) over() bj_fxyg,bl from table1 where dybm=1 and fl=0 and bj=1 and (cjsj>=to_date('2003-4-1 00:00:00','yyyy-mm-dd hh24:mi:ss') and cjsj<=to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss')) 或 select last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fxyg) over()-first_value(bj_fxyg) over() bj_fxyg,bl from table1 where dybm=1 and fl=0 and bj=1 and (cjsj between to_date('2003-4-1 00:00:00','yyyy-mm-dd hh24:mi:ss') and =to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss'))
to wl3721()兄:不行,我已经加过括号了,还是没有结果
我试了一下,好像就是无法实现cjsj大于一个时间而小于一个时间: SQL> select distinct last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fxyg) over()-first_value(bj_fxyg) over() bj_fxyg,bl from table1 where cjsj>=to_date('2003-4-1 00:00:00','yyyy-mm-dd hh24:mi:ss') and cjsj<=to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss'); 2 SQL> run 1* select distinct last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fx ERROR: ORA-01756: 括号内的字符串没有正确结束只要不用cjsj>=...and cjsj<=...,就可以出来结果 请问高手这是怎么回事?有解决的办法吗?
请高手指点一下会是什么地方出错了?
但是run的时候提示ERROR:ORA-01756: 括号内的字符串没有正确结束
and cjsj<=to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss'))
或
select last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fxyg) over()-first_value(bj_fxyg) over() bj_fxyg,bl from table1 where dybm=1 and fl=0 and bj=1 and (cjsj between to_date('2003-4-1 00:00:00','yyyy-mm-dd hh24:mi:ss') and =to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss'))
SQL> select distinct last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fxyg) over()-first_value(bj_fxyg) over() bj_fxyg,bl from table1 where cjsj>=to_date('2003-4-1 00:00:00','yyyy-mm-dd hh24:mi:ss') and cjsj<=to_date('2003-4-30 23:59:59','yyyy-mm-dd hh24:mi:ss');
2
SQL> run
1* select distinct last_value(bj_zxyg) over()-first_value(bj_zxyg) over() bj_zxyg,last_value(bj_fx
ERROR:
ORA-01756: 括号内的字符串没有正确结束只要不用cjsj>=...and cjsj<=...,就可以出来结果
请问高手这是怎么回事?有解决的办法吗?