我有2张桌子;表A和B.我的数据如下所示。我试图做两件事:
表A
姓氏..........邮编.....电话
测试.............. 00000 .... 555555555
测试.............. 00000 .... 111111111
测试................ 11111 ..... 99999999
表B
姓氏..........邮编.....电话
测试.............. 00000 .... 555555555
测试.............. 00000 .... 111111111
测试................ 11111 ..... 99999999
答案 0 :(得分:0)
这应该给你第一个答案
SELECT COUNT(A.Last Name) as namezipmatch
FROM A
INNER JOIN B ON A.LAST_NAME = B.LAST_NAME
WHERE
A.ZIP = B.ZIP
这应该给你第二个答案
SELECT COUNT(A.Last Name) as nameziphonematch
FROM A
INNER JOIN B ON A.LAST_NAME = B.LAST_NAME
WHERE
A.ZIP = B.ZIP AND A.PHONE = B.PHONE
答案 1 :(得分:0)
也许......如果访问权限允许您统计数据,则无法回想起。
SELECT count(Distinct B.Last_name + B.Zip) as CntLastZip,
count(Distinct C.Last_Name + C.Zip + C.Phone) as CntLastZipPhone
FROM TableA
LEFT JOIN tableB
ON A.Last_name = B.Last_Name
AND A.Zip = B.ZIP
LEFT JOIN tableC
ON A.Last_Name = C.Last-Name
AND A.Zip=C.Zip
AND A.Phone = C.Phone