需要在SQL中编写类似于pivot的SYBASE SP [英] Need To write a SYBASE SP similar To pivot in SQL
本文介绍了需要在SQL中编写类似于pivot的SYBASE SP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 SYBASE
I have a table like below in SYBASE
ID ENVI SERVER GROUP ACTIVE
== ==== ====== ====== ======
1 Developent AREGION_1 A 1
2 Developent AREGION_2 A 1
3 Developent AREGION_3 A 1
4 Developent BREGION_1 B 1
5 Developent BREGION_2 B 1
6 Developent BREGION_3 B 1
7 Developent CREGION_1 C 1
8 Developent CREGION_3 C 1
9 Developent A1REGION A 1
10 Developent A2REGION A 1
11 Developent ABCREGION A 1
i需要用输入参数ENVI写一个sp,它将返回如下结果
i need to write a sp with input Parameter ENVI that will return the result like below
ENVI A B C
==== ========= ========= =========
Development AREGION_1 BREGION_1 CREGION_1 (All servers Ending with _1)
Development AREGION_2 BREGION_2 (All servers Ending with _2)
Development AREGION_3 BREGION_3 CREGION_3 (All servers Ending with _3)
Development A1REGION
Development A2REGION
Development ABCREGION
条件是所有以_号结尾的服务器都应按第一个排序顺序排列。如果任何一列没有该行的值,则该字段应该为null或为空。任何组下随机名称的服务器必须放在该组的最后一个。
请帮我创建sp
提前感谢
the conditions Are All the servers ending with _ number should come in first sorted order. If any one column do not have value for the row that field should e null or empty. Any server with random name under any group must be placed last under that group.
Please help me creating the sp
thanks in advance
推荐答案
我和Oracle不太相似,但请看这些例子:
http://www.oracle-base.com/articles/11g/pivot-and- unpivot-operators-11gr1.php [ ^ ]
http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235.html [ ^ ]
http://www.orafaq.com/wiki/PIVOT [ ^ ]
http://www.oracle-developer.net/display.php?id=506 [ ^ ]
I''m not similar with Oracle, but see these examples:
http://www.oracle-base.com/articles/11g/pivot-and-unpivot-operators-11gr1.php[^]
http://www.oracle.com/technetwork/articles/sql/11g-pivot-097235.html[^]
http://www.orafaq.com/wiki/PIVOT[^]
http://www.oracle-developer.net/display.php?id=506[^]
这篇关于需要在SQL中编写类似于pivot的SYBASE SP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文