请教各位大哥

longchen2002 2012-11-17 04:23:00
今天帮人家写一个报表程序,其中一条要求把按时间统计普通医保和统筹医保,而区分是普通医保还是统筹医保是一个16位字符串,例如('8823181282228222'),如果是8则是统筹医保,其余的就是普通医保,如何可以正确统计。
...全文
199 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
longchen2002 2012-11-20
  • 打赏
  • 举报
回复
问题解决,谢谢啦!
  • 打赏
  • 举报
回复
加的虚拟列不可在sql处直接使用的,要不你就在sql处直接用字符截取,要不就用setfilter 或者用固定位数的查询 类似like '________8_______' sqlstring = sqlstring + ls_where dw_2.setsqlselect(sqlstring) li_number=dw_2.retrieve() sle_1.text=string(li_number) dw_2.setfocus() 注意顺序不要错了,filter是写在retrieve之后的//////============================================================================== //////// 根据输入病人性质确定检索条件 ////////============================================================================ if not isnull(dw_1.object.dwdz[1]) then dw_2.setfilter("T_1 = 1") //过滤统筹医保 dw_2.filter() 。。。。。。。。自己看一下F1 end if
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
datetime ldt_qsrq,ldt_zzrq string ls_where string sqlstring int li_number dw_2.settransobject(sqlca) dw_1.accepttext() dw_2.reset() sqlstring = "SELECT temp_jmtj.report_no, temp_jmtj.name, temp_jmtj.medical_card_no, temp_jmtj.age, temp_jmtj.sex,temp_jmtj.family_name, temp_jmtj.town, temp_jmtj.street, temp_jmtj.tel, temp_jmtj.report_date, temp_jmtj.credit_card_no, temp_jmtj.si_card_no,'' as t_1 FROM temp_jmtj where " ls_where="" ////============================================================================== //// 根据输入的体检日期段确定检索条件 ////============================================================================== ldt_qsrq = DateTime(Date(dw_1.Object.databegin[1]),Time("00.00.00")) ldt_zzrq = DateTime(Date(dw_1.Object.dataend[1]),Time("23.59.59")) ls_where = ls_where + " temp_jmtj.report_date>= '" + string(ldt_qsrq) + "' " + " and temp_jmtj.report_date<='" + string(ldt_zzrq) + "' " //////============================================================================== ////// 根据病人姓名确定检索条件 //////============================================================================== if not isnull(dw_1.object.xm[1]) then ls_where=ls_where+" and temp_jmtj.name like '"+trim(dw_1.object.xm[1])+"%'" end if //////============================================================================== ////// 根据输入的身份证号确定检索条件 //////============================================================================== If Not IsNull(dw_1.Object.cardid[1]) then ls_where = ls_where + " and temp_jmtj.medical_card_no= '" + trim(dw_1.Object.cardid[1]) + "'" End If //////============================================================================== ////// 根据输入家庭地址、工作单位确定检索条件 //////============================================================================== if not isnull(dw_1.object.jtdz[1]) then ls_where=ls_where+" and temp_jmtj.family_name like '"+trim(dw_1.object.jtdz[1])+"%'" end if //////============================================================================== //////// 根据输入病人性质确定检索条件 ////////============================================================================ if not isnull(dw_1.object.dwdz[1]) then ls_where=ls_where+" and SQ_GRDA.t_1 like '"+trim(dw_1.object.dwdz[1])+"%'" end if sqlstring = sqlstring + ls_where dw_2.setsqlselect(sqlstring) li_number=dw_2.retrieve() sle_1.text=string(li_number) dw_2.setfocus() 提示出错:列前缀‘SQ_GRDA’与查询中所用的表名或别名不匹配。
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
datetime ldt_qsrq,ldt_zzrq string ls_where string sqlstring int li_number dw_2.settransobject(sqlca) dw_1.accepttext() dw_2.reset() sqlstring = "SELECT temp_jmtj.report_no, temp_jmtj.name, temp_jmtj.medical_card_no, temp_jmtj.age, temp_jmtj.sex,temp_jmtj.family_name, temp_jmtj.town, temp_jmtj.street, temp_jmtj.tel, temp_jmtj.report_date, temp_jmtj.credit_card_no, temp_jmtj.si_card_no,'' as t_1 FROM temp_jmtj where " ls_where="" ////============================================================================== //// 根据输入的体检日期段确定检索条件 ////============================================================================== ldt_qsrq = DateTime(Date(dw_1.Object.databegin[1]),Time("00.00.00")) ldt_zzrq = DateTime(Date(dw_1.Object.dataend[1]),Time("23.59.59")) ls_where = ls_where + " temp_jmtj.report_date>= '" + string(ldt_qsrq) + "' " + " and temp_jmtj.report_date<='" + string(ldt_zzrq) + "' " //////============================================================================== ////// 根据病人姓名确定检索条件 //////============================================================================== if not isnull(dw_1.object.xm[1]) then ls_where=ls_where+" and temp_jmtj.name like '"+trim(dw_1.object.xm[1])+"%'" end if //////============================================================================== ////// 根据输入的身份证号确定检索条件 //////============================================================================== If Not IsNull(dw_1.Object.cardid[1]) then ls_where = ls_where + " and temp_jmtj.medical_card_no= '" + trim(dw_1.Object.cardid[1]) + "'" End If //////============================================================================== ////// 根据输入家庭地址、工作单位确定检索条件 //////============================================================================== if not isnull(dw_1.object.jtdz[1]) then ls_where=ls_where+" and temp_jmtj.family_name like '"+trim(dw_1.object.jtdz[1])+"%'" end if //////============================================================================== //////// 根据输入病人性质确定检索条件 ////////============================================================================ if not isnull(dw_1.object.dwdz[1]) then ls_where=ls_where+" and SQ_GRDA.t_1 like '"+trim(dw_1.object.dwdz[1])+"%'" end if sqlstring = sqlstring + ls_where dw_2.setsqlselect(sqlstring) li_number=dw_2.retrieve() sle_1.text=string(li_number) dw_2.setfocus() 提示出错:列前缀‘SQ_GRDA’与查询中所用的表名或别名不匹配。
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
if not isnull(dw_1.object.dwdz[1]) then ls_where=ls_where+" and SQ_GRDA.t_1 like '"+trim(dw_1.object.dwdz[1])+"%'" end if 提示出错:列前缀‘SQ_GRDA’与查询中所用的表名或别名不匹配。
  • 打赏
  • 举报
回复
可以,按照这两个虚拟列过滤就行了,用setfilter
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
我不是要合计人数,我是要如果选择统筹,那么数据窗口只显示统筹人员信息,如果选择普通,只显示普通人员信息。
  • 打赏
  • 举报
回复
引用 2 楼 longchen2002 的回复:
按照你的方法建立了虚拟列,可以显示出该病人是普通病人还是统筹病人,但如何筛选。数据库为sql2005
如果你加虚拟列,在summary区加两个计算列sum这两个字段, 其实用sql语句实现最好的了,你查一下sql2005的字符截取函数,把substr替换掉就行了
  • 打赏
  • 举报
回复
set T_1 = 2 就是dw_2.setitem(ll_row,'t_1','2')
  • 打赏
  • 举报
回复
sqlstring = sqlstring + ls_where dw_2.setsqlselect(sqlstring) li_number=dw_2.retrieve() // 统筹医保set t_1 = 1 long ll_row,ll_rowcount string ls_str ll_rowcount = dw_2.rowcount() for ll_row = 1 to ll_rowcount ls_str = dw_2.getitemstring(ll_row,'credit_card_no') ls_str = mid(ls_str,8,1) if ls_str = '8' then //统筹医保 set T_1 = 1 else //普通医保 set T_1 = 2 end if next //////// 根据输入病人性质确定检索条件 ////////============================================================================ string ls_str ls_str = dw_1.object.dwdz[1] //此处得到是1还是2,1为统筹,2为普通 if not isnull(ls_str) then dw_2.setfilter("t_1= '"+ls_str+"'") //过滤统筹医保 dw_2.filter() end if 或者直接在dw加个计算列 写表达式 if( mid(credit_card_no,8,1)= '8', '1', '2' )。 然后用filter根据这个表达式过滤
PB菜鸟 2012-11-19
  • 打赏
  • 举报
回复
引用 12 楼 longchen2002 的回复:
看来是我的赋值出错了,我是直接在数据窗口中用format属性中添加if( mid(credit_card_no,9,1)= '8', '统筹', '普通' )。但是你那个set赋值是在数据窗口中还是在程序中,在pb程序中有set T_1 = 1 这样赋值的吗?还请大哥多多指教。
过滤条件代码肯定写到你触发切换统筹或者普通医保时,如下拉框,单选按钮等,根据选择的条件,设置不同的过滤条件。设置过滤条件查看SetFilter() 函数。
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
看来是我的赋值出错了,我是直接在数据窗口中用format属性中添加if( mid(credit_card_no,9,1)= '8', '统筹', '普通' )。但是你那个set赋值是在数据窗口中还是在程序中,在pb程序中有set T_1 = 1 这样赋值的吗?还请大哥多多指教。
  • 打赏
  • 举报
回复
你确定你的t_1有值,你把值set进去了没有 试试dw_2.setfilter("t_1= '1'")
longchen2002 2012-11-19
  • 打赏
  • 举报
回复
datetime ldt_qsrq,ldt_zzrq string ls_where string sqlstring int li_number dw_2.settransobject(sqlca) dw_1.accepttext() dw_2.reset() sqlstring = "SELECT temp_jmtj.report_no, temp_jmtj.name, temp_jmtj.medical_card_no, temp_jmtj.age, temp_jmtj.sex,temp_jmtj.family_name, temp_jmtj.town, temp_jmtj.street, temp_jmtj.tel, temp_jmtj.report_date, temp_jmtj.credit_card_no, temp_jmtj.si_card_no,'' as t_1 FROM temp_jmtj where " ls_where="" ////============================================================================== //// 根据输入的体检日期段确定检索条件 ////============================================================================== ldt_qsrq = DateTime(Date(dw_1.Object.databegin[1]),Time("00.00.00")) ldt_zzrq = DateTime(Date(dw_1.Object.dataend[1]),Time("23.59.59")) ls_where = ls_where + " temp_jmtj.report_date>= '" + string(ldt_qsrq) + "' " + " and temp_jmtj.report_date<='" + string(ldt_zzrq) + "' " //////============================================================================== ////// 根据病人姓名确定检索条件 //////============================================================================== if not isnull(dw_1.object.xm[1]) then ls_where=ls_where+" and temp_jmtj.name like '"+trim(dw_1.object.xm[1])+"%'" end if //////============================================================================== ////// 根据输入的身份证号确定检索条件 //////============================================================================== If Not IsNull(dw_1.Object.cardid[1]) then ls_where = ls_where + " and temp_jmtj.medical_card_no= '" + trim(dw_1.Object.cardid[1]) + "'" End If //////============================================================================== ////// 根据输入家庭地址、工作单位确定检索条件 //////============================================================================== if not isnull(dw_1.object.jtdz[1]) then ls_where=ls_where+" and temp_jmtj.family_name like '"+trim(dw_1.object.jtdz[1])+"%'" end if sqlstring = sqlstring + ls_where dw_2.setsqlselect(sqlstring) li_number=dw_2.retrieve() //////// 根据输入病人性质确定检索条件 ////////============================================================================ if not isnull(dw_1.object.dwdz[1]) then dw_2.setfilter("t_1= 1") //过滤统筹医保 dw_2.filter() end if 怎么什么都检索不出来呀
longchen2002 2012-11-18
  • 打赏
  • 举报
回复
按照你的方法建立了虚拟列,可以显示出该病人是普通病人还是统筹病人,但如何筛选。数据库为sql2005
  • 打赏
  • 举报
回复
string ls_str = '8823181282228222' ls_str = mid(ls_str,8,1) 可在dw增加两虚拟列T_1,T_2 下面可用循环 if ls_str = '8' then 统筹医保 set T_1 = 1 else 普通医保 set T_2 = 1 end if 计算这两字段 还有一种就是用sql语句 以oracle为例 select sum(case when substr(字段,8,1) = '8' then 1 else 0 end) as T_1, //统筹医保 sum(case when substr(字段,8,1) <> '8' then 1 else 0 end) as T_2 //普通医保 from dual;