我有两张桌子,表A:
Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY
----------- ------- ------------ ---------- ---------- ---
123 AB 1/1/2012 111 222 1
123 AB 1/1/2012 111 222 1
456 AC 2/1/2012 333 444 1
和表B:
Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY
----------- ------- ------------ ---------- ---------- ---
123 AB 1/1/2012 111 222 2
456 AB 1/1/2012 124 111 1
我想匹配数据,以便表A中客户123的记录分组为:
Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY
----------- ------- ------------ ---------- ---------- ---
123 AB 1/1/2012 111 222 2
在表B的右边显示以下记录:
Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY
----------- ------- ------------ ---------- ---------- ---
123 AB 1/1/2012 111 222 2
另外(总有一个)我们想要在表A中显示第三条记录,在该记录右侧显示表B中的第二条记录(客户456),因为它们具有相同的Customer_ID,产品和销售日期
所以看起来应该是这样的
Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY Customer_ID Product Date Of Sale Pay Meth 1 Pay Meth 2 QTY
----------- ------- ------------ ---------- ---------- --- ----------- ------- ------------ ---------- ---------- ---
123 AB 1/1/2012 111 222 1 123 AB 1/1/2012 111 222 1
456 AC 2/1/2012 333 444 1 456 AB 1/1/2012 124 111 1