读书人

复杂的队列转换,求指导

发布时间: 2012-09-28 00:03:35 作者: rapoo

复杂的行列转换,求指导


这样的行列转换有什么比较好的方法来解决么.

想了一个晚上头疼死了.

解决了,另给100分

[解决办法]

SQL code
--用js呀?with t(LeafClass,c1,c2,property,value) as(select 1,'xxx','xx','name','leaf1'union select 1,'xxx','xx','color','red'union select 2,'xxxx','xxxxx','height','1000')select LeafClass,c1,c2,isnull(name,'') name,isnull(color,'') color,isnull(height,'') height from t     pivot(max(value) for property in(name,color,height)) a;/*LeafClass   c1   c2    name  color height----------- ---- ----- ----- ----- ------1           xxx  xx    leaf1 red   2           xxxx xxxxx             1000(2 row(s) affected)*/
[解决办法]
这数据库的东西吧,怎么放js版块来了
一种是查询出所有记录后另外写代码进行遍历处理,这个好写
另一种是数据库内进行,sqlserver的话可以用游标实现这个转换
[解决办法]
读取到数组里就好了

读书人网 >JavaScript

热点推荐