首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

大家看上,这个sql语句如何写

2012-09-20 
大家看下,这个sql语句怎么写字段名是list,里面的值我截取的这几行数据0800:1600:1.000600:1400:2200:1.000

大家看下,这个sql语句怎么写
字段名是list,里面的值我截取的这几行数据
0800:1600:1.00  
0600:1400:2200:1.00  
0800:2000:2.00  
0800:4.00  
0800:1.00  

我现在想把它的格式转换下,换成这样(最后一个:后面代表的是一个特殊值,我现在要把它跟前面的0800,1600之类的数据拼凑一下)
0800:1;1600:1
0600:1;1400:1;2200:1
0800:2;2000:2
0800:4
0800:1

值的内容都不一定,我记得好像有个语句是直接可以实现的,忘记了
望谁能讲解下。 
 
 


[解决办法]

SQL code
拼的很。。。。。select '0800:1600:1.00' as list union all   select '0600:1400:2200:1.00' union all     select '0800:2000:2.00' union all     select '0800:4.00' union all     select '0800:1.00' select replace(REVERSE(substring(REVERSE(list),charindex(':',REVERSE(list)),(len(list)-charindex(':',REVERSE(list))))),':',':'+REVERSE(substring(REVERSE(list),0,charindex(':',REVERSE(list))))+';') from (select '0800:1600:1.00' as list union all   select '0600:1400:2200:1.00' union all     select '0800:2000:2.00' union all     select '0800:4.00' union all     select '0800:1.00' )as tables--------------------800:1.00;1600:1.00;600:1.00;1400:1.00;2200:1.00;800:2.00;2000:2.00;800:4.00;800:1.00;(所影响的行数为 5 行) 

热点排行