¸ù¾ÝÒ»ÁеÄÊý×ÖÉú³É×ÖĸµÝÔö,
ÈçijÁÐΪ
2
1
3
4
2
5
Òª²éѯ½á¹ûΪ
AÁÐ BÁÐ
2 a,b
1 a
3 a,b,c
4 a,b,c,d
2 a,b
5 a,b,c,d,e
лл
Êý×ֻᳬ¹ý26Âð£¿....ÈçºÎ
¹Ø×¢£¡
²»»á³¬¹ý26,
SQL code:
--> ²âÊÔÊý¾Ý£º[tb]
if object_id('[tb]') is not null drop table [tb]
create table [tb]([A] int)
insert [tb]
select 2 union all
select 1 union all
select 3 union all
select 4 union all
select 2 union all
select 5
--º¯Êý
create function dbo.getcharacter(@id int)
returns varchar(8000)
as
begin
declare @ret varchar(8000)
select @ret=isnull(@ret+',','')+code
from
(select char(number) as code
from master..spt_values
where type = 'P' and number >= 65 and number <= 65+@id-1
) t
return @ret
end
--²éѯ
select A,dbo.getcharacter(A) as B
from tb
-----------------------
2 A,B
1 A
3 A,B,C
4 A,B,C,D
2 A,B
5 A,B,C,D,E
ÄÇÄãÊÇ·ñÓиöÊÇ1-26,A-Z¶ÔÓ¦
SQL code:
--ҪСд¾ÍÓÃ
select A,lower(dbo.getcharacter(A)) as B
from tb
²»»á³¬¹ý26£¬ÎÒ
СµÜ£¬×î½üҪתÐÐÈ¥×öoracle¿ª·¢ÁË£¬ÓÉÓÚ´óѧ±Ïҵʱ£¬×ßÁ˸öÍä·£¬ÏÖÔÚºÜСÐÄ£¬ÎÊÏ£¬×öPL/SQLÓÐûÓÐǰ;£¿£¿£¿
µ±È»ÎÒ˵µÄÕâ¸öǰ;ÊÇÖ¸ ÒÔºóÒªÌø²Û£¬Êг¡¶ÔÕâÑùµÄÈ˲ŵÄÐèÇóÁ¿´ó²»´ó£¿£¿
3q ÄÇ¿´À´»¹Ö»ÄÜÏȽӴ ......