求一个查询语句,挑战大家. :)(50分)

  • 主题发起人 主题发起人 5411
  • 开始时间 开始时间
5

5411

Unregistered / Unconfirmed
GUEST, unregistred user!
原表 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;对应方式 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 所要结果<br>A &nbsp;-------------------- B &nbsp; &nbsp; &nbsp;一个对一个以上 &nbsp; &nbsp; &nbsp; &nbsp; A ------------------B<br>A &nbsp;-------------------- C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;null --------------- C<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;计数(行数) &nbsp; &nbsp; &nbsp;计数(行数)<br>################################################################################<br>A ----------------------B &nbsp; &nbsp; &nbsp;一个以上对一个 &nbsp; &nbsp; &nbsp; &nbsp; A ----------------- B<br>C ----------------------B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C ------------------null<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;计数(行数) &nbsp; &nbsp; &nbsp;计数(行数)<br>###############################################################################<br>A ---------------------- B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;A ------------------B<br>C ---------------------- B &nbsp; &nbsp; &nbsp; &nbsp; 网络式对应 &nbsp; &nbsp; &nbsp; &nbsp; C ------------------D &nbsp;<br>C ---------------------- D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; null ----------------E<br>A ---------------------- E &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 计数(行数) &nbsp; &nbsp; &nbsp;计数(行数)
 
看不明白.
 
网络对应模式看不懂。
 
一个语句不好搞,用存储过程或者程序代码吧.<br>分析了以下,LZ主要是想将首次出现的记录保留,后面的某一个出现了就为null<br>那么至少还有一个Id 字段,假设排序的次序也是按该Id升序的,<br>1.取一条记录,假设字段为Fa,Fb,将Fa,Fb放到一个临时表temp1,字段为Ft,将fa,fb放入临时表temp2,字段ffa,ffb (ffa = fa),(ffb=fb)<br>2.取下一条记录,<br>3.判断Fa是否在temp1.ft里面,不在就添加到temp1,ft, 在就添加到temp2,ffa, <br>4.判断fb是否在temp1.ft里面,不在就添加到temp1,ft, 在就添加到temp2,ffb, <br>5.循环第2步骤,直到记录完<br><br>获得的temp2就是需要的数据
 
join &nbsp;方式
 
后退
顶部