日期:2014-05-16  浏览次数:20695 次

sql查询求助
select 
  tc.order_no,
  tc.customer_nm_kn_sei_disp,
  tc.customer_nm_kn_mei_disp,
  tc.customer_nm_kj_sei,
  tc.customer_nm_kj_mei,
  tc.expand_address_kj1,
  tc.expand_address_kj2,
  tc.sub_address_kj1,
  tc.sub_address_kj2,
  tc.tel1,
  tc.tel2,
  tc.tel3,
  tc.mobile_tel1,
  tc.mobile_tel2,
  tc.mobile_tel3,
  tc.create_date,
  tcr.management_date,
  tcr.resend_kbn
from
  TB_CUSTOMER_ATTR tc,
  TB_CUSTOMER_ATTR_RESEND tcr 
where
  tc.delete_flg = '0' AND 
  tcr.resend_kbn(+) = '00' AND
  tcr.delete_flg(+) = '0' AND
  tc.general_account_kbn = '10' AND
  tc.order_no = tcr.order_no(+) 
order by tc.create_date

现在想增加一个tcr.resend_kbn(+) = '99' 
本来想用union连接2个条件的,但是tc.order_no有重复怎么解决?

------解决方案--------------------
贴建表及插入记录的SQL,及要求结果出来看看

用DISTINCT不行?
------解决方案--------------------
有重复你想怎么做,取重复的哪一条
------解决方案--------------------
(不要高估你的汉语表达能力或者我的汉语理解能力)
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
 
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
 
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。


------解决方案--------------------
我怎么 tcr.resend_kbn(+) = '00' AND 这句报错