我有几个具有UDID(唯一ID)的表和一些其他信息。我正在尝试组合这些表,以便每个UDID在最终表中出现一次。我所有输入表中的数据看起来都是正确的,并且具有良好的理论意义。但是,当我查看输出表时,我一遍又一遍地看到相同的数据。
以下是查询:
create table roi_wide_ss_gen_all as
select a.udid, a.src, a.tm8,a.tm7,a.tm6,a.tm5,a.tm4,a.tm3,a.tm2,a.tm1, a.t1, a.t2, a.t3, a.t4, a.t5,a.t6,a.t7,a.t8
, pf_m, female, asam, pf_50, pf_150, pf_250, pf_251
from roi_wide_ss_gen a
left outer join roi_wide_ss_gen_m b on (a.udid = b.udid)
left outer join roi_wide_ss_gen_f c on (a.udid = c.udid)
left outer join roi_wide_ss_gen_k d on (a.udid = d.udid)
left outer join roi_wide_ss_gen_50 e on (a.udid = e.udid)
left outer join roi_wide_ss_gen_150 f on (a.udid = f.udid)
left outer join roi_wide_ss_gen_250 g on (a.udid = g.udid)
left outer join roi_wide_ss_gen_251 h on (a.udid = h.udid)
left outer join roi_wide_ss_gen_as i on (a.udid = i.udid)
;
以下是输出表的前几行:
udid src tm8 tm7 tm6 tm5 tm4 tm3 tm2 tm1 t1 t2 t3 t4 t5 t6 t7 t8 pf_m female asam pf_50 pf_150 pf_250 pf_251
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
如果我让这个继续100行,那么数据最终会改变一点,比如
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
2b4821ecf223b1f6 1 0 0 0 0 4 6 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
a6ce599b8344bb4c 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
3f1448b00f8d8031 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 1 1 0 0 0 0 0
fca0bd81bdc66de5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0
fca0bd81bdc66de5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0
但它仍然不是每个UDID一行,就像大多数UDID一样。我可以发誓过去我的工作正常,但是......
答案 0 :(得分:1)
您的某个表格中应该有重复的udid
- 如果您对udid
没有唯一约束,请检查
select udid from ... group by udid having count(*) > 1
在你的桌子上找出