select R.YEARMONTH, R.RQ, X.SPCODE, X.NAME, W.CODE + substring(W.NAME,1,30) WLDW, R.DEPTID, B.DEPT_NAME , R.HTH, K.JSKL HTKL, R.JSKL,
R.XSSL,(R.XSJE+R.YHJE) XSHJ, R.XSCB, R.XSJE, R.YHJE, R.ZKJE, R.ZKFTJE,
convert(money,VIPFTCB /(1-R.JSKL)) VIPZKJE,
( 1 - V.FTBL )*100 FTBL ,
convert( money, XSCB * X.JXSL ) - R.VIP_FTJE FKJE ,
( case isnull(R.HDZKJE,0) when 0 then ' ' else '是' end ) ZJJSBJ,
( case isnull(R.HDZKBJ,0) when 0 then ' ' else '是' end ) HDZKBJ,
R.HDZKBL*100 HDZKBL,
R.XYK_FTJE,
R.VIP_FTJE,
R.JSD_JLBH
from LYSPJSR R , SPXX X , WLDW W, HT_LY_JSKL K, HT_VIPZKFT V, BM B
where X.SP_ID=R.SP_ID
and X.GHDW=W.CODE
and K.HTH=R.HTH
and B.DEPTID=R.DEPTID
and K.CODE=X.JSKL_CODE
and V.VIPTYPE=8
and V.HTH=R.HTH
order by R.YEARMONTH, R.RQ, W.CODE, X.SPCODE