CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  MS-SQL Server >  应用实例

求一SQL语句,在固定行中为表添加一个临时编号,其余行置空

楼主geniusqing(依帆)2005-06-04 17:42:06 在 MS-SQL Server / 应用实例 提问

create   table   test(clothid   varchar(10),number   varchar(10),bagid   varchar(10))  
  insert   into   test  
  select   '11-11','56','1'  
  union   all   select   '11-12-1','45','1'  
  union   all   select   '11-12-2','46','1'  
  union   all   select   '11-12-3','50','2'  
  union   all   select   '11-13-1','60','2'  
  union   all   select   '11-13-2','32','2'  
  union   all   select   '11-14','34','3'  
  union   all   select   '11-15-1','45','3'  
  union   all   select   '11-15-2','52','3'  
  结果如下:  
  id   number   bagid     clothid                                    
  1     56               1         11-11  
  2     45               1         11-12-1  
  3     46               1         11-12-2  
  4  
  5  
  1     50               2         11-12-3  
  2     60               2         11-13-1  
  3     32               2         11-13-2  
  4  
  5  
  1     34               3         11-14  
  2     45               3         11-15-1    
  3     52               3         11-15-2  
  4    
  5  
  4,5可以显示也可以不显示,请问这样可以实现吗  
  问题点数:40、回复次数:1Top

1 楼yjdn(人形机器)回复于 2005-06-04 18:20:27 得分 40

--楼主,还没解决吗?不是说4,5也可不以不显示的吗?  
  select   id=(select   count(*)   from   test   where   left(bagid+clothid,3)=left(a.bagid+a.clothid,3)   and   clothid<=a.clothid)  
  ,   number   ,bagid,clothid  
  from   test   aTop

相关问题

  • 求一SQL语句,为一个表添加一个临时编号?
  • 求一SQL语句,在固定行中为表添加一个临时编号,其余行置空
  • 求一SQL语句,在固定行中为表添加一个临时编号,急?????
  • 添加的SQL语句怎么写?
  • 如何用sql语句删除一个临时表?
  • 急问:动态执行Sql语句与临时表?
  • 求教判断临时表存在的SQL语句。。。。急
  • sql语句,临时表操作基础问题
  • sql语句 求分隔字符串转临时表
  • SQL语句中如何得到自动添加的id号?

关键词

  • clothid
  • bagid
  • union all select
  • 显示
  • varchar

得分解答快速导航

  • 帖主:geniusqing
  • yjdn

相关链接

  • SQL Server类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo