

SELECT B.FBalance, A.FCardId,SUM(A.FInBalance) - SUM(A.FOutBalance)
FROM TEmployeeCard AS B,TEmployeeCardBill AS A
WHERE A.FCardId = B.FCardId
GROUP BY A.FCardId,B.FBalance
HAVING ABS(SUM(A.FInBalance) - SUM(A.FOutBalance) - B.FBalance) != 0


SELECT A.FCompId,A.FBillTime,FBizType,A.FBillId,A.FInBalance,A.FOutBalance,A.FBalance,A.FBalance + FOutBalance - FInBalance
 FROM TEmployeeCardBill AS A WHERE FCardId = 5633336480342400506
ORDER BY FBillTime DESC

SELECT * FROM TEmployeeCard WHERE FCardId = 5633336480342400506
SELECT * FROM TEmployeeCardBill WHERE FCardId = 5633336480342400506
ORDER BY FBillTime desc

UPDATE TEmployeeCardBill SET FBalance = FBalance - 1 WHERE FBillTime >= '2020-06-04 11:06:18.000'
AND FCardId = 4734077965941970269

PRecalcCardAccHistBalance 5633336480342400506

UPDATE TEmployeeCard SET FBalance = 102.000000
WHERE FCardId = 4734077965941970269

SELECT * FROM T