当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·呵,终于有了五个绿角角,    »显示摘要«
    摘要: 高兴! ......
 ·sql语句简单问题(在线)    »显示摘要«
    摘要: 在table1表中 动态查寻文本筐的内容是(name是字符型的) strquery = "select * from table1 where name = " & "" + text1.text + "" with adodc1 .recordsource = strquery .refresh end with 可若是......


这种情况的SQL语句

table:  
  name     type     nbr  
  X           a           1  
  Y           b           1  
  Z           b           1  
  X           c           1  
   
  结果:  
   
  name     a       b       c  
  X           1               1  
  Y                   1  
  Z                   1

NO.1   作者: happydreamer

declare   @sql   varchar(8000)  
  set   @sql   =   select     name,  
   
  select   @sql   =   @sql   +   sum(case   type   when   +type+    
                                                      then   nbr   else   0   end)   as   [+type+],  
      from   (select   distinct   nbr   from   表)   a  
   
  select   @sql   =   left(@sql,len(@sql)-1)   +     from   表   group   by   name  
   
  exec(@sql)  
  go  
 

NO.2   作者: pengdali

或:  
   
  declare   @sql   varchar(8000)  
  set   @sql   =   select   name  
  select   @sql   =   @sql   +   ,sum(case   type   when   +type+   then   数据   end)   as   [+type+]  
      from   (select   distinct   type   from   [table])   as   a  
  select   @sql   =   @sql+   from   [table]   group   by   name  
   
  exec(@sql)  
  go


 ·怎样获得本机的计算机名称    »显示摘要«
    摘要: 如题,谢谢 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE