首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

如何用[^]相加

2012-09-03 
怎么用[^]相加例:SQL codeidvalue----------------------------------------------------122438得到要 2^4

怎么用[^]相加

例:

SQL code
id                        value----------------------------------------------------1                         22                         43                         8

得到要 2^4^8的值14


[解决办法]
sum([value])
[解决办法]
SQL code
declare @str varchar(20)set @str='';with tas(select 1 as id,2 as valueunion allselect 2 ,4union allselect 3,8)select @str=@str+'^'+ltrim(value) from tselect right(@str,len(@str)-1) as valuevalue2^4^8
[解决办法]
SQL code
declare @str int;with tas(select 1 as id,2 as valueunion allselect 2 ,4union allselect 3,8)select @str=isnull(@str,0)^value from tselect @str/*-----------14(1 行受影响)*/ 

热点排行