100分,请教一个作业语句写法!

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

有一电影网站广告联盟,我想在每天晚上12点时,进行如下处理:  
  统计今天所有会员,如果有会员的代理注册用户超过12个,8元一个,也就是有满百元的就结算,  
  自动在表中添加一个期数,  
  然后,把这些满足条件的会员的期数定义为,刚才自动添加的期数,如果今天没有超过百元的,就不自动添加期数,就不结算。  
   
  这是是否有满百元的asp语句,  
  sql="select   userid   from   [ads]   where   flag=1     and   qishu   is   null     group   by   userid   having   count(userid)>12"  
   
   
   
  这是添加期数的asp语句,  
   
  rs.open   "select   *   from   bigclass2   where   bigclassname="   &   bigclassname   &   "",conn,1,3  
  rs.addnew  
   
  这是结算的asp语句  
  sql="select   *   from   ads     where   userid="&userid&"   and   qishu   is   null     and   flag=1     "  
  rs("qishu")=qishu  
   
  请问这个作业语句怎么写,谢谢!  
   
 

· 网友精彩回答:

发表者:xluzhong

if   exists(select   userid   from   [ads]   where   flag=1     and   qishu   is   null     group   by   userid   having   count(userid)>12)  
        ---添加  
  else  
        --不添加  
 

发表者:xluzhong

if   exists(select   userid   from   [ads]   where   flag=1     and   qishu   is   null     group   by   userid   having   count(userid)>12)  
        ---添加  
        insert   into   存储表  
        select   *   from   bigclass2   where   bigclassname=变量  
  else  
        --不添加

发表者:qjt

写一个存储过程  
  create   procedure   a  
                    @p1   varchar(50),    
  @userid   int  
  as  
  if   exists(select   userid    
                    from   [ads]    
                    where   flag=1     and   qishu   is   null     group   by   userid   having   count(userid)>12)  
  begin  
          insert   into   bigclass2  
          select   *   from   bigclass2   where   bigclassname=@p1  
          select   *   from   ads     where   userid=@userid   and   qishu   is   null     and   flag=1      
  end  
   
  如何在asp中调用该存储过程  
   
   
   
 

发表者:qjt

你的期数是否是‘整数型’,若是  
  在存储过程中改成下面的语句  
  declare   @qishu   int  
  select   @qishu=max(qishu)   from   bigclassname  
  set   @qishu=@qishu+1  
  insert   into   bigclass2  
  values(......,@qishu,...)  
   
   
 

发表者:qjt

不用循环啊  
   
  if   满百元的用户存在  
      期数+1  
  update   classname  
  set   qishu=@qishu  
  select   *   from   数据库  
  where   满足的条件  
   
  不知我说清楚了没有!

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved