有表如下:表明 :Goods
编号 名称
GS001 A
... ....
GS999 N
GS1000 B当执行下列语句时:Select Max(编号) from Goods 时 每次查询出来的都是GS999的记录如何查询出GS1000这条记录,也是说不管是GS后面的数字是多少,必须取得数字最大的一个值,而不是按照字符排列的最大的值,如何解决!
编号 名称
GS001 A
... ....
GS999 N
GS1000 B当执行下列语句时:Select Max(编号) from Goods 时 每次查询出来的都是GS999的记录如何查询出GS1000这条记录,也是说不管是GS后面的数字是多少,必须取得数字最大的一个值,而不是按照字符排列的最大的值,如何解决!
解决方案 »
- SNMP
- TeamSource安装不了!!帮帮忙!!!!
- 程序运行时出错了,弹出消息Property ExtendedDuplex does not exist,高手指点一下
- 打印form上所有的东西
- 怎么判断用户单击dbgrid时,行发生了变化!谢谢!
- 刚刚完成了一个程序,从Win2K换到Win98下调试发现界面全部变形了!怎么解决?给100分!
- 我求大家了!!!
- 图像模糊识别的问题
- 这个想法应该怎么来实现? ************ 在线等 *************
- 如何把一个删除的文件恢复(没有放到回收站),用程序如何实现(可以给到200分,绝不食言)
- CodeGear最新筹备了中文论坛,大家赶快去注册吧!
- delphi报表
from goods
where 编号=(
select 'GS'+max(cast(substring(编号,3,10) as int))
from goods
)
CREATE TABLE [tttt] (
[Col001] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL,
[Col002] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GOinsert into tttt
select 'GS001','1' union all
select 'GS999','2' union all
select 'GS1000','3' union all
select 'HY998','4' union all
select 'HY999','5' union all
select 'HY1000','6' union all
select 'BT1001','7' select * from tttt
where col001 in (
select max(substring(col001,1,2))+
convert(varchar,max(convert(int,substring(col001,3,len(col001) -2))))
from tttt
group by substring(col001,1,2)
)if exists (select * from dbo.sysobjects where id = object_id(N'[tttt]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [tttt]
GO-------------
result:GS1000 3
HY1000 6
BT1001 7