use chongqing_xinchao SELECT COMP.FNo + '-' + COMP.FAbbr AS 门店, M.FName AS 姓名, M.FMobilePhone AS 手机, C.FCardNo as 卡号, T.FNo + '-' + T.FName AS 卡类别, H.FTime AS 扣费时间, CAST(H.FOutAmount AS FLOAT)AS 扣费金额, cast(CA.FBalance AS FLOAT) AS 最新余额 FROM TMemberCardAcctHist AS H INNER JOIN TMemberCard AS C ON C.FCardId = H.FCardId INNER JOIN TMember AS M ON M.FMemId = C.FMemId INNER JOIN TMemberCardType AS T ON T.FId = C.FTypeId INNER JOIN TMemberCardAccount AS CA ON CA.FCardId = C.FCardId AND CA.FAcctId =3 INNER JOIN TCompany AS COMP ON COMP.FId = C.FCompId WHERE H.FBizType = 'SMSFee' AND H.FAcctId = 3 ORDER BY COMP.FNo,FCardNo