select max(cast(replace(ID,'A','') as int)) from TB
测试过了,1楼4楼是对的,另外6楼中也可以不用cast转换,即select max(replace(ID,'A','')) from TB
declare @s varchar(10) set @s='A11' select right(@s,len(@s)-1)
declare @t table([Name] varchar(10)) insert @t select 'A1' union all select 'A2' union all select 'A3' union all select 'A4' union all select 'A5' union all select 'A6' union all select 'A7' union all select 'A8' union all select 'A9' union all select 'A10' union all select 'A11' select max(cast(stuff([Name],1,1,'')as int)) from @t
select max(cast(substring(colname,2,len(colname)-1) as int)) from tb
SELECT max(STUFF(ID,1,1,'')) FROM TB
select max(cast(replace(ID,'A','') as int)) from TB select max(cast(stuff(ID,1,1,'')as int)) from TB
要转换啊 [SQL code] SELECT max(cast (STUFF(ID,1,1,'')as int)) FROM TB [/Quote]
SELECT max(STUFF(ID,1,1,'')) FROM TB
set @s='A11'
select right(@s,len(@s)-1)
insert @t select 'A1' union all select
'A2' union all select
'A3' union all select
'A4' union all select
'A5' union all select
'A6' union all select
'A7' union all select
'A8' union all select
'A9' union all select
'A10' union all select
'A11'
select max(cast(stuff([Name],1,1,'')as int)) from @t
SELECT max(STUFF(ID,1,1,'')) FROM TB
select max(cast(replace(ID,'A','') as int)) from TB
select max(cast(stuff(ID,1,1,'')as int)) from TB
要转换啊
[SQL code]
SELECT max(cast (STUFF(ID,1,1,'')as int)) FROM TB
[/Quote]