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

43 lines
1.2 KiB

1 year ago
use kunming_yefa
DROP TABLE #Source
SELECT A.FBillId,A.FBillNo,A.FBillTime,B.FMemCourseId,B.FPurTimes,B.FPurAmount into #Source
FROM
TMemberSaleBill AS A,TMemberSaleExchangeSource AS B
WHERE A.FBillId = B.FBillId
AND B.FMemCourseId IN(SELECT FId FROM TMemberCourse WHERE FCompID != 3472894337749090304)
AND A.FCompId= 3472894337749090304
SELECT * FROM #Source
SELECT A.FBillId,A.FBillNo,A.FBillTime,B.FMemCourseId,B.FPurTimes,B.FPurAmount into #Source
FROM
TMemberSaleBill AS A,TMemberSaleExchangeSource AS B
WHERE A.FBillId = B.FBillId
AND B.FMemCourseId IN(SELECT FId FROM TMemberCourse WHERE FCompID != 3472894337749090304)
AND A.FCompId= 3472894337749090304
SELECT * FROM TMemberSaleBill as a,TMemberSaleExchange AS B
WHERE A.FBillId IN(SELECT FBillId FROM #Source)
AND A.FBillId = B.FBillId
AND FCardId IN(SELECT FCardId FROM TMemberCard WHERE FCompId = 3472894337749090304)
SELECT SUM(FPurAmount) FROM #Source
SELECT SUM(FPurAmount) FROM TMemberSaleCourse
WHERE FBillId IN(SELECT FBillId FROM #Source)
SELECT * FROM #Source
WHERE FBillId IN(
SELECT FBillId FROM TMemberSaleCourse
WHERE FBillId IN(SELECT FBillId FROM #Source)
)
3472894337749090304
SELECT * FROM TCompany