是这样,我这里有一个统计上报的功能,如果日期为空,那么为未报,如果有日期,则比较日期;6号前为按时上报,之后为延时上报;上报数据存储采用TIMESTAMP(6),比较时是采用查询日期条件to_date(2010||'-'||06||'-06', 'yyyy-MM-dd')
这里的数字是我替换掉变量写的
我想返回日期在6号后的,返回1,6号以前的返回2;可是只能返回1
我在表里看到有按时上报的数据,所以这里数据查询语句写的有点问题,请高手指点下
case when monthplan.created is null then 0
when monthplan.created >= to_date(2010||'-'||06||'-06', 'yyyy-MM-dd') then 1
else 2 end as reportState
这里的数字是我替换掉变量写的
我想返回日期在6号后的,返回1,6号以前的返回2;可是只能返回1
我在表里看到有按时上报的数据,所以这里数据查询语句写的有点问题,请高手指点下
case when monthplan.created is null then 0
when monthplan.created >= to_date(2010||'-'||06||'-06', 'yyyy-MM-dd') then 1
else 2 end as reportState
解决方案 »
- truncate和index的问题
- oracle 中extent的设置
- 这sql该怎么写?⊙﹏⊙ 、我实在憋不出来、纠结了
- Oracle 0基础求学者请教
- 求助 oracle透明网关配置问题
- 请问,如何配置oracle 10g Transparent Gateway程序连接到DB2 UDB V8.1 for windows数据库?
- 查看Oracle数据库操作
- 高手急救:安装Oracle Data Provider For .net出错。
- oracle 数据库 用pro c 来批量插数据出错怎么才能打印出哪个数据有问题?
- SYSTEM或DBA如何对普通用户进行相互授权?
- Oracle9i 升级到Oracle10g 需要注意什么?
- 求购一个如下要求的 SQL
例如: 2010-07-03的数据,应该是按时上报的,但是按你这个写出来,就是未按时上报了。
我这里没有Oracle,所以没有写出SQL,就是只比较 MM-DD就可以了,很简单的不知道我理解的对不对,呵呵
举个例子:可是查询条件传进去的是2010-06,在SQL语句中又添加了06合成2010-06-06为上报日期to_date(:par_yearN||'-'||:par_monthN||'-25', 'yyyy-MM-dd')那么我要是调用5月25号到6月25号的数据,这个where条件该如何写呢?monthplan.reportdate >= to_date(:par_yearN||'-'||:par_monthN||'-25', 'yyyy-MM-dd') and monthplan.reportdate < to_date(:par_yearN||'-'||:par_monthN||'-25', 'yyyy-MM-dd')
?
'com.bjcx.emergency.report.actionform.SafetyMonthPlanDetailActionFormQuery_'||:par_yearN ||'_'||:par_monthN||'_'||:par_deptId||'_'||companyid as id
,companyid
,companyname
,companycode
,monthplanid
,decode(countx,0,reportState,3) reportState
from (
select comdisplay.companyname
,comdisplay.companycode
,comdisplay.companyid
,monthplan.monthplanid
,(select count(*)
from bms_companyinfo cominfo
where cominfo.parentid = comdisplay.companyid
and cominfo.logyes = 1
and cominfo.companytype in (0,2,4,6,8)) as countx
,case
when
monthplan.created is null then 0
when monthplan.reportdate >= to_date(:par_yearN||'-'||:par_monthN||'-06', 'yyyy-MM-dd')
and monthplan.reportdate < to_date(:par_yearN||'-'||:par_monthN||'-25', 'yyyy-MM-dd') then 1
else 2 end as reportState
from view_company_sum comsum
left join dms_safetymonthplan monthplan
on comsum.compid = monthplan.deptid
and monthplan.yearn = :par_yearN
and monthplan.reportdate >= to_date(:par_yearN||'-'||(to_number(:par_monthN)-1)||'-25', 'yyyy-MM-dd')
and monthplan.reportdate < to_date(:par_yearN||'-'||:par_monthN||'-25', 'yyyy-MM-dd')
join view_company_display comdisplay
on comsum.compid = comdisplay.companyid
and comsum.compid = comdisplay.topid
where comsum.topid = :par_deptId and comdisplay.companyid > 21
) src
where reportState = :par_reportState
order by companycode这个在PL/SQL中替换所有变量执行通过的,但是在jboss下报错,提示:建立会话异常,请高手指点下,这个正确的写法该是怎么样的?