标签:style blog ar color sp on div log bs
假设字符串中只由‘A‘、‘B‘、‘C‘、‘D‘组成,且长度为7。并设函数REPLICATE(<字符串>,<n>)可以创建一个<字符串>的n个副本的字符串,另外还有REPLACE(<目标字符串>,<老字符串>,<新字符串>),实现如下:
1 BEGIN 2 DECLARE inString CHAR(7); 3 SET inString = ‘DCDBAAB‘; 4 5 REPLICATE(‘A‘, (DATA_LENGTH(inString)-DATA_LENGTH(REPLACE(inString,‘A‘,‘‘)))) 6 || 7 REPLICATE(‘B‘, (DATA_LENGTH(inString)-DATA_LENGTH(REPLACE(inString,‘B‘,‘‘)))) 8 || 9 REPLICATE(‘C‘, (DATA_LENGTH(inString)-DATA_LENGTH(REPLACE(inString,‘C‘,‘‘)))) 10 || 11 REPLICATE(‘D‘, (DATA_LENGTH(inString)-DATA_LENGTH(REPLACE(inString,‘D‘,‘‘)))) 12 13 END;
标签:style blog ar color sp on div log bs
原文地址:http://www.cnblogs.com/geekpaul/p/4117111.html