Board logo

标题: 请教管理员,下面的sql语句如何按时间来传递参数 [打印本页]

作者: lfmhr    时间: 2012-5-19 10:37     标题: 请教管理员,下面的sql语句如何按时间来传递参数

select un_name,count(*) as '出生数',
sum(case cb_childsex when '男' then 1 else 0 end) as '男',
sum(case cb_childsex when '女' then 1 else 0 end) as '女'   
from
dbo.csrk_view,unitname
where 1=1
and cb_birthdate >='2009-11-01' and cb_birthdate<='2010-10-31' and hd_belongunit is not null
and  hd_belongunit=un_id
and un_cityid = '469022000000'
and hd_inputday-cb_birthdate >=30
group by un_name


上面的语句中传递参数渗格式要怎么写:
and cb_birthdate >='2009-11-01' and cb_birthdate<='2010-10-31' and hd_belongunit is not null
and  hd_belongunit=un_id
and un_cityid = '469022000000'
and hd_inputday-cb_birthdate >=30

我想在web应该用系统将字段为:开始时间、结束时间 传递给cb_birthdate,不知该如何写我的传参的语句。

[ 本帖最后由 lfmhr 于 2012-5-19 10:42 编辑 ]
作者: admin    时间: 2012-5-24 12:05

你在 <form> 里设置 两个field,名称在sql定义里引用,就行了。如下所示:
-----------------------------
web 表单写法:
-----------------------------
<form action='reportviewer?file=a.xml'>
<input name='beginDate'/>
<input name='endDate'/>
<form>


-----------------------------
设计器中 sql写法:
-----------------------------
and cb_birthdate >='${beginDate}' and cb_birthdate<='${endDate}' and hd_belongunit is not null
and  hd_belongunit=un_id
and un_cityid = '469022000000'
and hd_inputday-cb_birthdate >=30
作者: admin    时间: 2012-5-24 12:06

通过url传递参数也可以,如:

iframe.src = "jor/reportviewer?file=a.xml&beginDate=2011-1-12&endDate=2011-12-1";
作者: lfmhr    时间: 2012-5-29 21:40     标题: 请问日“从字符串转换日期和/或时间时,转换失败"该如何解决。

请问日“从字符串转换日期和/或时间时,转换失败"该如何解决。




欢迎光临 杰表技术论坛 (http://bbs.jatools.com/) Powered by Discuz! 6.1.0