当前位置:首页 » 系统开发

我在表中有一单号字段,怎样显示出中间没有用的单号?请进来看详细内容。谢谢!

类型:转载   责任编辑:asp   日期:2007/03/01

    

我有一单号字段:如下  
    单号  
    wl0001  
    wl0002  
    wl0004  
    rp0001  
    rp0002  
    rp0003  
    rp0006  
   
  其中   单号列少了wl0003     rp0004     rp0005  
  这样就表示销售人员漏单,我怎么样找出漏的这些单?非常感谢!


网友回答:
网友:zjcxc

--测试表  
  create   table   表(单号   varchar(10))  
  insert   into   表  
  select   wl0001  
  union   all   select   wl0002  
  union   all   select   wl0004  
  union   all   select   rp0001  
  union   all   select   rp0002  
  union   all   select   rp0003  
  union   all   select   rp0006  
  go  
   
  --得到编号缺号的字符列表  
  if   exists   (select   *   from   dbo.sysobjects   where   id   =   object_id(n[dbo].[f_getnseries])   and   xtype   in   (nfn,   nif,   ntf))  
  drop   function   [dbo].[f_getnseries]  
  go  
   
  create   function   f_getnseries(@head   varchar(10))  
  returns   varchar(8000)  
  as  
  begin  
  declare   @re   varchar(8000),@id   int,@h   varchar(10)  
  select   @re=,@id=0,@h=@head+%  
  select   @re=case   @id   when   id-1   then   @re  
  else   @re+,+@head+right(0000+cast(@id+1   as   varchar),4)  
  +case   @id+1   when   id-1   then    
  else   -+@head+right(0000+cast(id-1   as   varchar),4)   end  
  end  
  ,@id=id  
  from   (select   id=cast(right(单号,4)   as   int)   from   表   where   单号   like   @h)   a  
  set   @re=substring(@re,2,8000)  
  return(@re)  
  end  
  go  
   
  --调用实现你的要求  
  select   dbo.f_getnseries(aa)   from(  
  select   distinct   aa=left(单号,2)   from   表  
  )   a  
   
  go  
  drop   table   表  
   
  /*--测试结果  
  -------------------  
  rp0004-rp0005  
  wl0003  
   
   
   
  --*/

.


其它问题:
1、一个简单的算数问题!来者有分!

请问各位老大在Delphi中怎么样判断一个数字是奇数呀!

 
2、各位请问如何在网页中做一个treeview的东西?

有人做过吗?

 
3、可不可以把工程上的图纸扫描变成CAD文件呢

可不可以把工程上的图纸扫描变成CAD文件呢  
 

 


标签:

发表新评论

  • 网页地址和电子邮件地址将会被自动转换为链接。
  • 允许的 HTML 标签: <p> <br> <a> <img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 行和段被自动切分。