单独选择联动的参数显示数据

image.png

怎么根据已有的科目、客商、项目单独选出一条查出需要的数据,例如,选择场地租赁,显示的都是所有场地租赁的数据,但是我选了一个,报错,列名无效,另外这三个是和部门联动的

select 科目,客商,项目,sum((case when  表='T1' then 预收 else 0 end ) ) 预收,sum((case when 表='T1' then 冲销 else 0 end )) 冲销,

sum((case when 表='T2' then 预收 else 0 end ) ) 赊销,

sum((case when 表='T2' then 冲销 else 0 end ) ) 收款

 from 

( select 'T1' 表,科目,客商,项目,yskje 预收,cxje 冲销 from (

   select (select name  from uf_bd_account where uf_bd_account.id=d.km) 科目,

   (select name  from uf_bd_cust_supplier where uf_bd_cust_supplier.id=d.khmc) 客商,

   (select project_name  from uf_bd_project where uf_bd_project.id=d.xm) 项目,

    yskje,cxje  from uf_gl_voucher_dt1 d  where mainid in(select id from uf_gl_voucher where 1=1

${if(len(bumen) == 0,""," and orgcode in (" + bumen + ")")}

${if(len(starttime)=0,""," and prepareddate>='"+starttime+"'")}

${if(len(endtime)=0,""," and prepareddate<='"+endtime+"'")}  ))x

where 1=1

${if(len(km) == 0,""," and 科目 in (" + km + ")")}

${if(len(ks) == 0,""," and 客商 in (" + ks + ")")}

${if(len(xm) == 0,""," and 项目 in (" + xm + ")")}

union all

select 'T2',科目,客商,项目,sxje 赊销 ,skjine 收款  

from (

   select (select name  from uf_bd_account where uf_bd_account.id=d.kem) 科目,

   (select name  from uf_bd_cust_supplier where uf_bd_cust_supplier.id=d.keh) 客商,

   (select project_name  from uf_bd_project where uf_bd_project.id=d.xiangm) 项目,

    sxje,skjine  from uf_gl_voucher_dt2 d where mainid in(select id from uf_gl_voucher where 1=1

${if(len(bumen) == 0,""," and orgcode in (" + bumen + ")")}

${if(len(starttime)=0,""," and prepareddate>='"+starttime+"'")}

${if(len(endtime)=0,""," and prepareddate<='"+endtime+"'")} ))x

where 1=1

${if(len(km) == 0,""," and 科目 in (" + km + ")")}

${if(len(ks) == 0,""," and 客商 in (" + ks + ")")}

${if(len(xm) == 0,""," and 项目 in (" + xm + ")")}

)x

group by 科目,客商,项目

这是数据集

FineReport 18328816101 发布于 2019-5-7 11:44 (编辑于 2019-5-7 11:50)
1min目标场景问卷 立即参与
回答问题
悬赏:4 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
18328816101Lv5中级互助
发布于2019-5-7 14:25

sql小错误,没注意in后面的参数是字符串,需要加上单引号

最佳回答
1
ldwl66Lv2见习互助
发布于2019-5-7 14:40

in后面的参数是字符串

加上单引号

试试

最佳回答
0
PoseidonLv5高级互助
发布于2019-5-7 11:45

就根据你选择的变量做过滤啊;

你数据集怎么写的?

  • 18328816101 18328816101(提问者) 我加了数据集
    2019-05-07 11:50 
  • Poseidon Poseidon 回复 18328816101(提问者) 1、先写死看看行不行; 2、如果可以证明你传递参数部队,看下SQL日志
    2019-05-07 11:55 
  • 18328816101 18328816101(提问者) 回复 Poseidon 写死不行,com.fr.general.data.TableDataException: 错误代码:11300001 数据集配置错误 Server workspace no response. 而且一直出现connection pool shut down
    2019-05-07 12:02 
  • 2关注人数
  • 694浏览人数
  • 最后回答于:2019-5-7 14:40
    请选择关闭问题的原因
    确定 取消
    返回顶部