资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

求SQL?

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

表A   
  id       id_c     kc_i  
  1         001         0  
  2         001         1  
  3         002         0  
  6         002         0  
  4         003         1  
  5    003         2    
  7         003         0  
   
  求结果  
  id       id_c     kc_i  
  2         001         1  
  3         002         0  
  4         003         1  
  5         003         2  
   
   
  意思是:当表中有相同的id_c时,如果有kc_i<>0   ,kc_i为0的删除.  
                                                              但如果kc_i都为0,则要保留一条。                  
   
   
 

网友回答:

发表者:zjcxc

delete   a   from   a   aa  
  where   kc_i=0   and(  
  exists(select   *   from   a   where   id_c=aa.id_c   and   kc_i<>0)  
  or  
  exists(select   *   from   a   where   id_c=aa.id_c   and   kc_i=0   and   id<a.id))


 

 
热门推荐笔记本: IBM笔记本
相关文章:
笔记本相关:
IT技术文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved