帆软下: select tta.mdmc,tta.spid,tta.spmc,ttb.xszje from (select ta.mdmc,ta.louceng,ta.spid,ta.spmc,tb.xsze from (select * from zg_sysinfo where 1=1 ${if( len(fine_username)== 0 , "", "and mdmc='"+门店+"' and louceng in (select distinct louceng from jhyb_user where mdmc='"+门店+"' and name = '"+fine_username+"' )" )} )ta join (select mdmc,loudong,louceng,quyu,spid,spmc,sum(xsze)xsze from view_xshb where rq>='${format(datedelta(开始日期,-14),"yyyy-MM-dd")}' and rq<='${结束日期}' group by mdmc,loudong,louceng,quyu,spid,spmc ) tb on ta.mdmc=tb.mdmc and ta.louceng=tb.louceng and ta.spid=tb.spid )tta left join (select mdmc,loudong,louceng,quyu,spid,spmc,xsbs,xsze xszje from view_xshb where rq='${结束日期}' ) ttb on tta.mdmc=ttb.mdmc and tta.louceng=ttb.louceng and tta.spid=ttb.spid where ttb.xszje is null order by tta.mdmc,tta.spid asc SQL下: select tta.mdmc,tta.spid,tta.spmc,ttb.xszje from (select ta.mdmc,ta.louceng,ta.spid,ta.spmc,tb.xsze from (select * from zg_sysinfo where mdmc='江北店' and louceng in (select distinct louceng from jhyb_user where mdmc='江北店' and name = 'ysbin' ) )ta join (select mdmc,loudong,louceng,quyu,spid,spmc,sum(xsze)xsze from view_xshb where rq>='2023-1-24' and rq<='2023-2-7' group by mdmc,loudong,louceng,quyu,spid,spmc ) tb on ta.mdmc=tb.mdmc and ta.louceng=tb.louceng and ta.spid=tb.spid )tta left join (select mdmc,loudong,louceng,quyu,spid,spmc,xsbs,xsze xszje from view_xshb where rq='2022-2-7' ) ttb on tta.mdmc=ttb.mdmc and tta.louceng=ttb.louceng and tta.spid=ttb.spid where ttb.xszje is null order by tta.mdmc,tta.spid asc 报表是为了查:最近14天有销售,但是当天没销售的。 一模一样的查询条件,帆软下面就是加了个用户权限表的部门条件和开始结束时间。 我在SQL下面条件直接输入值,秒出结果。在帆软里面计算不出来,请大神帮忙看下。 |