jsp的sql和oracle中的sql查询结果不同?
sqlplus中
select * from chaowei where riqi in(select min(riqi) from chaowei
where riqi between '2008-09-01 09:12' and '2008-09-27 09:12'
Group By substr(riqi,0,15)) order by riqi asc;
结果:
BIANHAO ZHANDIANID RIQI D1 RECORDRIQI
---------- ---------- ------------------------- ---------- -------------------------
4 481 2008-09-20 16:50:02 6.7 2008-09-20 16:50:02
7 481 2008-09-20 18:09:38 3.8 2008-09-20 18:09:38
10 481 2008-09-20 19:00:08 4.7 2008-09-20 19:00:08
24 481 2008-09-20 20:58:35 7.8 2008-09-20 20:58:35
1 481 2008-09-21 10:25:14 3.4 2008-09-21 10:25:14
31 481 2008-09-23 15:24:00 5.6 2008-09-23 15:26:00
25 481 2008-09-25 09:20:00 4.5 2008-09-25 09:22:00
27 481 2008-09-25 15:06:00 4.5 2008-09-25 15:08:00
36 481 2008-09-25 19:53:00 4.5 2008-09-25 19:55:00
37 481 2008-09-26 14:52:00 5.8 2008-09-26 14:54:00
已选择10行。
在jsp页面中
"select * from chaowei where riqi in(select min(riqi) from chaowei where riqi between to_date('"+date1+"','yyyy-mm-dd hh24:mi') and to_date('"+date2+"','yyyy-mm-dd hh24:mi') Group By substr(riqi,0,15)) order by riqi asc";date1,date2分别对应上面两个时间
结果:
4 481 2008-09-20 16:50:02 6.7 2008-09-20 16:50:02
1 481 2008-09-21 10:25:14 3.4 2008-09-21 10:25:14
31 481 2008-09-23 15:24:00 5.6 2008-09-23 15:26:00
25 481 2008-09-25 09:20:00 4.5 2008-09-25 09:22:00
37 481 2008-09-26 14:52:00 5.8 2008-09-26 14:54:00
为什么得到的结果不一样呢?怎么修改两者才能一致?
我把jsp中的substr(riqi,0,15)中的15改成1,只查到一条记录,改成>2的任何数(包括100,200任意大数)得到的都是
结果:
4 481 2008-09-20 16:50:02 6.7 2008-09-20 16:50:02
1 481 2008-09-21 10:25:14 3.4 2008-09-21 10:25:14
31 481 2008-09-23 15:24:00 5.6 2008-09-23 15:26:00
25 481 2008-09-25 09:20:00 4.5 2008-09-25 09:22:00
37 481 2008-09-26 14:52:00 5.8 2008-09-26 14:54:00
郁闷,substr()不起作用了吗?快帮帮我把!
------解决方案--------------------
------解决方案--------------------substring(0,15)????oracle中好像是从1开始吧
------解决方案--------------------oracle 是从1开始的
------解决方案--------------------用substr(riqi,0,10)试下
在ORACLE里开始你用0或1是一样的,0会被默认为1