我遇到了将column1的值与column2和column3匹配的问题。我想要的只是显示column1中的所有数据,其中匹配值为column1的匹配数据。例如:
+----------------+--------------+
|SB_AccNo |CLAIM INITATED|
+----------------+--------------+
|122000031730 |1854.36 |
|122000031730 |4172.31 |
|122000031730 |5099.49 |
|122000069210 |54.56 |
|122000069210 |54.56 |
|122000069210 |14998.50 |
|122000069210 |27317.25 |
+----------------+--------------+
+---------------+---------------+
|SB_AccNo1 |CLAIM INITATED1|
+---------------+---------------+
|122000031730 |1483.00 |
|122000031730 |3338.00 |
|122000031730 |4080.00 |
|122000069210 |11999.00 |
|122000069210 |21854.00 |
|122000070281 |1091.00 |
|122000070281 |1091.00 |
+---------------+---------------+
+---------------+---------------+
|SB_AccNo2 |CLAIM INITATED2|
+---------------+---------------|
|122000031730 |371.00 |
|122000031730 |834.00 |
|122000031730 |1019.00 |
|122000069210 |3000.00 |
|122000069210 |5463.00 |
|122000070281 |273.00 |
|122000070281 |273.00 |
|122000070281 |954.00 |
|122000070281 |3272.00 |
+---------------+---------------+
我想将列SB_AccNo,SB_AccNo1和SB_AccNo2匹配为相同的值。每列可能包含多次相同的值。我希望它们仅在匹配时显示。谁能帮我吗?? 输出应该像
SB_AccNo CLAIM INITATED SB_AccNo1 CLAIM INITATED1 SB_AccNo2CLAIM INITATED2
122000031730 1854.36 122000031730 1483.00 122000031730 371.00
122000031730 4172.31 122000031730 3338.00 122000031730 834.00
122000031730 5099.49 122000031730 4080.00 122000031730 1019.00
122000069210 54.56 122000069210 11999.00 122000069210 3000.00
122000069210 54.56 122000069210 21854.00 122000069210 5463.00
122000069210 14998.50 122000070281 1091.00 122000070281 273.00
122000069210 27317.25 122000070281 1091.00 122000070281 273.00
122000070281 1363.50 122000070281 3818.00 122000070281 954.00
122000070281 1363.50 122000070281 13090.00 122000070281 3272.00
122000070281 4772.25 122000070281 16362.00 122000070281 4091.00
122000070281 16362.00 122000070281 17453.00 122000070281 4363.00
答案 0 :(得分:1)
听起来,你需要像这样的SQL
只需检查WHERE
子句中的每个值是否匹配。
SELECT SB_AccNo, [CLAIM INITATED]
, SB_AccNo1, [CLAIM INITATED1]
, SB_AccNo2, [CLAIM INITATED2]
FROM MyTable
WHERE SB_AccNo = SB_AccNo1 AND
SB_AccNo = SB_AccNo2 AND
SB_AccNo1 = SB_AccNo2
编辑:为SQL添加了字段名称 你确定它是INITATED而不是INITIATED吗?