根据专柜汇总会员卡消费

根据专柜汇总会员卡消费明细:
declare @RQ1 datetime,@RQ2 datetime

select B.DEPTID,B.DEPT_NAME,L.SKTNO,L.JLBH,convert(char,S.JYSJ,102) SJ,X.HYID,X.HYK_NO,X.HY_NAME,sum(L.JE) JE,sum(L.JF) JF
 from BFCRM.HYXFJL L,BFCRM.HYK_HYXX X,BFBHDD.SKTXSJLC C,BFBHDD.BM B,BFBHDD.SKTXSJL S
where L.HYID=X.HYID
  and L.SKTNO=C.SKTNO
  and L.JLBH=C.JLBH
  and S.SKTNO=C.SKTNO
  and S.JLBH=C.JLBH
  and C.DEPTID=B.DEPTID
  and L.JZRQ>=@RQ1
  and L.JZRQ<=@RQ2
group by B.DEPTID,B.DEPT_NAME,L.SKTNO,L.JLBH,S.JYSJ,X.HYID,X.HYK_NO,X.HY_NAME
order by X.HYID,S.JYSJ
查询界面:


相关参数:

你可能感兴趣的:(sql,职场,休闲)