作者sleepwu ( )
看板Database
标题[SQL ] 资料结构不同的join问题
时间Tue Aug 26 19:21:24 2014
资料库名称:SQL server 2008
内容/问题描述:
因为不太好描述,我将table简化,请直接点连结看图。
我有两张table如
http://tinyurl.com/pconsga
其中ABC栏都是string,A and B and C是key值,D E栏用来判断number2的属性。
我拿table2 right join table 2 on 1.A=2.A and 1.B=2.B and 1.C=2.C
结果因为key值重复,会显示为table3,但我想要呈现为table4的样子。
http://tinyurl.com/k4lssjz
请问这种资料结构该怎麽join或是怎麽group?
感谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 202.89.121.16
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Database/M.1409052087.A.31B.html
1F:→ smlboby: 把 table3 当 subquery, 再包一层做 group by 也可以 08/28 10:24