Listparts and vmsys. vm_concat: Convert rows into columns and separate them with commas.
Difference: listparts is a new function added in 11.2, and this function can be used to sort in groups.
-- The vmsys. vm_concat function is grouped by department as follows. The same group is separated by commas (,) in a row.Select deptno, wmsys. wm_concat (ename) from EMP group by deptno;
Listparts function:
Sys_connect_by_path function:
Select sys_connect_by_path (ename ,',')From (select ename, deptno, ro
From: http://blog.csdn.net/seventh1984/archive/2009/02/26/3940168.aspx
I personally think this function is actually very useful. sys_connect_by_path (field name, The Connection Symbol between two fields). Note that the Connection Symbol here should not be a comma. Oracle will report an error. If you must use it, replace can be used as follows: Replace (field name, original character ,',').Also, you must create a tree before using this function. Otherwise, it is useless.For example:Objective: To
for the difference between these 3 functions, and is the most easily overlooked. See there are a lot of comparisons on this 3 functions on the web. These are rarely involved. What I'm going to say here is the difference between checking for variables that already exist.
code is as follows
nbs P;
$a =100; $b = ""; $c =null;nbs P //isset Check echo "Isset", "$a = $a", isset ($a)? " Define ":" Www.111cN.net undefine ", R
representative SQL method.SELECT country, max (substr (city, 2) cityFROM(SELECT country, sys_connect_by_path (city, ',') cityFROM(SELECT country, city, country | rn rchild, country | (rn-1) rfatherFROM(SELECT test. country, test. city, row_number () over (partition by test. country order by test. city) rn FROM test ))Connect by prior rchild = rfather start with
principle. Here is a representative SQL method.Select Country, max (substr (city, 2) CityFrom(Select Country, sys_connect_by_path (city, ',') CityFrom(Select country, city, country | rn rchild, country | (rn-1) rfatherFrom(Select test. Country, test. City, row_number () over (partition by test. Country order by test. City) Rn from test ))Connect by prior rchild
Use sys_connect_by_path to convert multiple rows into single-row strings.
Recently, several projects have the need to convert multiple rows into strings. Now we will write an example for your reference.
Create a table and insert data:
Create Table t_row_str (
ID number,
Col varchar2 (10 ));
Insert into t_row_str values (1, 'A ');
Insert into t_row_str values (1, 'B ');
Insert into t_row_str values (1, 'C ');
Insert into t_row_str values (2, 'A ');
Insert into t_row_str values (2, 'D ');
Insert i
values ('t502', 'x1', 3)
Insert into tb1 values ('t503', 'x1', 53)Insert into tb1 values ('t503', 'x1', 44)Insert into tb1 values ('t503', 'x1', 50)Insert into tb1 values ('t503', 'x1', 23)
-- Auto-increment is required in sqlserver2000.Alter table tb1 add ID int identityGoDeclare @ s varchar (8000)Set @ s = 'select cpici'Select @ s = @ s + ', max (case when Rn =' + ltrim (RN) + 'then cvalue end) as cvlue
values ('t502', 'x1', 3)
Insert into tb1 values ('t503', 'x1', 53)Insert into tb1 values ('t503', 'x1', 44)Insert into tb1 values ('t503', 'x1', 50)Insert into tb1 values ('t503', 'x1', 23)
-- Auto-increment is required in sqlserver2000.Alter table tb1 add ID int identityGoDeclare @ s varchar (8000)Set @ s = 'select cpici'Select @ s = @ s + ', max (case when Rn =' + ltrim (RN) + 'then cvalue end) as cvlue
want to talk about the differences in checking all the existing variables. the code is as follows:
$ A = 100;
$ B = "";
$ C = null;
// Isset check
Echo "isset", "$ a = $ a", isset ($ )? "Define": "undefine", "rn ";
Echo "isset", "$ B = $ B", isset ($ B )? "Define": "undefine", "rn ";
Echo "isset", "$ c = $ c", isset ($ c )? "Define": "undefine", "
provides many new commands.
(1) The clz Rd, RM ---- zero count command is used to calculate the number of zeros between the highest sign bit and the first 1.
This command is useful in speech/audio codec normalization operations. For example, using armv4 ISA to implement forward zero count may use several commands.
(2) qadd Rd, RM, RN --- RD = SAT (RM + rn)
Qdadd Rd, RM,
)Bool (true)Bool (false) Is_null.It can be seen that empty () can be used to determine whether all data types are NULL or false, while is_null is basically the same as isset and can only be used to determine whether it is NULL or undefined.To sum up the differences among isset, empty, and is_null:As described earlier: checking variables and parameter types are the basis for the differences between the three functions and are also the most overlooked. I can see many articles comparing these thre
differences between the three functions and are also the most overlooked. I can see many articles comparing these three functions on the Internet. This is rarely involved. Next I want to talk about the differences in checking all existing variables.
The Code is as follows:$ A = 100;$ B = "";$ C = null;// Isset checkEcho "isset", "$ a = $ a", isset ($ )? "Define": "www.111cN.net undefine", "rn ";Echo "isset", "$ B = $ B", isset ($ B )? "Define": "unde
difference between these 3 functions, and is the most easily overlooked. See there are a lot of comparisons on this 3 functions on the web. These are rarely involved. What I'm going to say here is the difference between checking for variables that already exist.
The code is as follows
Copy Code
$a = 100; $b = ""; $c =null; //isset Check echo "Isset", "$a = $a", isset ($a)? " Define ":" Www.111cN.net undefine "," RN "
test values (' Nvwang ', ' Ye ');
INSERT into test values (' Happy ', ' Leaf ');
Commit
3. Query
Sql> select * from test;
Dname ename
---------- ----------
Guowang Andy
Guowang Zhang
Guowang Chong
Nvwang Tao
Nvwang Ye
Happy Leaf
6 rows selected.
Target Conversion Mode:
Dname NAME
---------- ----------------
Guowang Andy,zhang,chong
Nvwang Tao,ye
Happy Leaf
4. Conversion
Method One:
A simple way to pass a function, with Oracle versioning as an alternative.
Sql> col name for A40
Sql> Select D
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 Conntect by problem SQL: 1. The most common method of connect by is www.2cto.com select SYS_CONNECT_BY_PATH (sal, ',') from (select sal, ROW_NUMBER () over (partition by deptno order by sal) rn, ROW_NUMBER () over (partition by deptno order by sal)-1 as dn from scott. emp where deptno = '20') start with rn = 1 connect by prior
involved. Next I want to talk about the differences in checking all existing variables.
The code is as follows:
$ A = 100;$ B = "";$ C = null;// Isset checkEcho "isset", "$ a = $ a", isset ($ )? "Define": "undefine", "rn ";Echo "isset", "$ B = $ B", isset ($ B )? "Define": "undefine", "rn ";Echo "isset", "$ c = $ c", isset ($ c )? "Define": "undefine", "
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.