You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sql-tools/检查余额和账户历史.sql

80 lines
997 B

1 year ago
SELECT * FROM
(
SELECT FCardId,FAcctId,FBalance
FROM TMemberCardAccount
) AS T1,
(
SELECT FCardId,FAcctId, SUM(FInAmount) - SUM(FOutAmount) AS FBalance
FROM TMemberCardAcctHist
GROUP BY FCardId,FAcctId
) AS T2
WHERE T1.FCardId = T2.FCardId
AND T1.FAcctId = T2.FAcctId
AND T2.FBalance != T1.FBalance
UPDATE A
SET A.FBalance = T2.FBalance
FROM TMemberCardAccount AS A,
(
SELECT FCardId,FAcctId, SUM(FInAmount) - SUM(FOutAmount) AS FBalance
FROM TMemberCardAcctHist
GROUP BY FCardId,FAcctId
) AS T2
WHERE a.FCardId = T2.FCardId
AND a.FAcctId = T2.FAcctId
AND a.FBalance != T2.FBalance
SELECT * FROM
(
SELECT FMemId,FMemNo,FPoint
FROM TMember
) AS T1,
(
SELECT FMemId, SUM(FInAmount) - SUM(FOutAmount) AS FPoint
FROM TMemberPointHist
GROUP BY FMemId
) AS T2
WHERE T1.FMemId = T2.FMemId
AND T2.FPoint != T1.FPoint
--
1 8
41 1e0001
--
1 8
41 1e0001
--
1 8
e5 1e0001
--
1 8
e5 1e0001
--
1 8
e5 1e0001