Order WM_CONCAT
HelloIs it possible to put the values in the WM_CONCAT function:
Statement:
wm_concat (rental_next_date) rental_date,
Output:
25-FEB-11,25-OCT-12,25-APR-12,25-DEC-11,25-APR-11
The above dates is controllable by Crescent?
Thank you
sliderrules wrote:
Thank you all for your comments. The listagg has no effect on the order of dates.
That's because you ordered solely on the id. If you want to order on the dates, you will have to ask him.
Tags: Database
Similar Questions
-
When ran the following query, I got the enames unordered result. Does anyone know how to get the wm_concat to the order\sort column? I use oracle v10. Any thoughts are appreciated. Thank you.
Select distinct deptno, wm_concat (ename) over (partition by deptno arrested by deptno) as enames
WCP
Ename, deptno group
order by deptno
output current:
The target output:DEPTNO ENAMES 10 MILLER,CLARK,KING 20 SCOTT,JONES,FORD,ADAMS,SMITH 30 MARTIN,JAMES,WARD,ALLEN,TURNER,BLAKE
WanwanDEPTNO ENAMES 10 CLARK,KING,MILLER 20 ADAMS,FORD,JONES,SCOTT,SMITH 30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
wm_concat is undocumented. so please do not use it. You can use the following query. It also solves your problem order.
select deptno, ltrim(sys_connect_by_path(ename,','),',') from (select deptno, ename, row_number() over(partition by deptno order by ename) rno from emp) where connect_by_isleaf = 1 connect by deptno = prior deptno and rno = prior rno+1 start with rno = 1
-
How can'i use wm_concat in ODI 10
Hello
I would like to know how to use the wm_concat function in an ODI interface (I use 10 ODI)
For example, I have the following source data
A B C
--- --- -------
20 5 SMITH
30 3 ALLEN
30 2 WARD
20 4 JONES
30 2 MARTIN
30 3 BLAKE
10 1 CLARK
20 3 SCOTT
10 3 KING
30 5 TURNER
20 2 ADAMS
30 5 JAMES
20 1 FORD
10 5 MILLER
and I want to insert the next data kes
A sum(B) wm_concat(c)
--- --- ------------------------
10 9 CLARK,KING,MILLER
20 15 SMITH,FORD,ADAMS,SCOTT,JONES
30 20 ALLEN,BLAKE,MARTIN,TURNER,JAMES,WARD
by adding a function of sum () in the column mapping B.
The following query generates the ODI
SELECT A, SUM (B), WM_CONCAT (C) FROM <table> GROUP BY A, WM_CONCAT (C);
This means that the ODI does not recognize WM_CONCAT as aggregate function.
don't you think that it is possible to say ODI to do not function in the group by
PS: I use an Oracle 11 g database 2 which recognizes the WM_CONCAT function.
Thank you very much
Hello
WM_Concat is no longer valid, that it has been deprecated by oracle, a long time ago.
Using the LISTAGG function instead... It should work in ODI...
SELECT deptno, LISTAGG (ename, ',') INTRA GROUP (ORDER BY ename) as employees
WCP
GROUP BY deptno;
DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK, KING, MILLER
ADAMS, FORD, JONES 20, SCOTT, SMITH
ALLEN, JAMES, MARTIN, BLAKE, TURNER, WARD 30
If this solves your problem... close the thread...
Thank you
ASP.
-
Reg: WMSYS. WM_CONCAT or LISTAGG
All,
I'm trying to select column names that begin with "E" in my sql query projection area. For this I used USER_TAB_COLS with WMSYS. WM_CONCAT / LISTAGG too.
I got the names of columns, with separator ", but could not inject it to the sql query. Please help me.
SQL > SELECT WMSYS. WM_CONCAT (column_name)
2 FROM user_tab_cols
3 WHERE table_name = 'EMP '.
4 AND column_name LIKE '% E ';WMSYS. WM_CONCAT (COLUMN_NAME)
--------------------------------------------------------------------------------
EMPNO, ENAMESQL > SELECT
2. (SELECT WMSYS. WM_CONCAT (column_name)
3 FROM user_tab_cols
4 WHERE table_name = 'EMP '.
5 AND COLUMN_NAME LIKE '% E '.
(6) a
7 FROM EMP where rownum < = 4;A
--------------------------------------------------------------------------------
EMPNO, ENAME
ERROR:
ORA-22922: non-existent LOB value-LISTAGG
SQL > select (selection ListAgg (column_name, ',')
2 IN THE GROUP (ORDER BY COLUMN_NAME DESC) AS CONCATV
3 to user_tab_cols
4. WHERE TABLE_NAME = 'EMP '.
5 AND COLUMN_NAME LIKE '% E') a FROM EMP WHERE ROWNUM < = 3;A
----------------------------------------------------------------------------------------------------
ENAME, EMPNO
ENAME, EMPNO
ENAME, EMPNOThank you
Here is an example of what you want to do:
: c is of type cursor
declare
v varchar2 (4000);
Start
Select GROUP(ORDER BY COLUMN_NAME DESC) AS CONCATV ListAgg (column_name, ',')
v
of user_tab_cols
WHERE TABLE_NAME = 'MYTABLE ';
Open: c for 'select'. v. "from MYTABLE";
end;
----
Ramin Hashimzade
-
lines due to the wm_concat() in double request gorge yourself
Here's the query I need to run
SELECT the separate user interface. Index_name, UI. Owner, UI. Table_name, wm_concat (uic.column_name) on column_name (partition by order of position_colonne uic.index_name), the ui.index_type, the parameters
Of
all_IND_COLUMNS UI all_INDEXES JOIN UIC
ON UIC. INDEX_NAME = UI. INDEX_NAME
where
SUBSTR (UI.index_name, 1, 3) not IN ("PK_", 'UQ_', ' DR$ ")
and ui.index_name not like 'SYS_C00% '.
and ui.index_name not like 'SYS_IOT_TOP_ %' and owner = 'USER1 '.
control of the user interface. INDEX_NAME
The problem is wm_concat() because the all_IND_COLUMNS table contains the entry duplicated for index (index1 of the table(column1,column2,column3) type)
for this wm_concat returns the result as below:
--------------------
Column1
Column1, Column2
Column1, Column2, Column3
But in * result I don't need it for a particular name of index (separate index)
as an example, I have two indexes in schema:
index1 on table1 (column1, column2, column3) and
Index2 on table2 (column5)
This result need
Row1 - index1 Column1, Column2, Column3
Index2 column 5 row2-
my query returns
index1 Column1 row1-
row2 - index1 Column1, Column2
row3 - index1 Column1, Column2, Column3
row4 - column 5 index2Are you trying this?
SELECT UI.INDEX_NAME, ui.owner , UI.TABLE_NAME , ui.index_type, parameters, listagg(column_name,',') within GROUP ( ORDER BY column_position) column_name FROM all_INDEXES UI JOIN all_IND_COLUMNS UIC ON ( UIC.INDEX_NAME = UI.INDEX_NAME and uic.index_owner = ui.owner) WHERE SUBSTR(ui.index_name,1,3) NOT IN ('PK_', 'UQ_','DR$') AND ui.index_name NOT LIKE 'SYS_C00%' AND ui.index_name NOT LIKE 'SYS_IOT_TOP_%' GROUP BY UI.INDEX_NAME, ui.owner , UI.TABLE_NAME , ui.index_type, parameters ORDER BY UI.INDEX_NAME;
-
How do I get the data in order by date
Hello
I get the data as below, I need the data with null values
Date col1 col2 col3 col4
16 November 11 23
November 17 11 12
18 November 11 321
19 November 11 23
20 November 11 132
2321 16 November 11
17 November 11 112
18 November 11 211
19 November 11 132
November 20, 11 12
16 November 11 45
17 November 11 465
2123 18 November 11
19 November 11 132
20 November 11 65
16 November 11 456
17 November 11 546
4656 November 18, 11
19 November 11 566
20 November 11 564
need output like below
Date col1 col2 col3 col4
16 November 11 23 2321 45 456
November 17 11 12 112 465 546
18 November 11 321 211 2123 4656
19 November 11 23 132 132 566
20 November 11 132 12 65 564
Thanks in advance,
Vincent.Delighted ADIK wrote:
Please post requests INSERT such as requested by another user of the forum. Also mention the version of Oracle.Please search for WM_CONCAT.
http://www.Oracle-base.com/articles/Misc/StringAggregationTechniques.php
Yes, search for WM_CONCAT, and then COMPLETELY IGNORE IT because it is not the right way to do things. It is undocumented and should not be used similarly recommended.
Even Tom Kyte says that you should not use it...
Re: SEPARATE does not not with wmsys.wm_concat
WM_CONCAT is also an aggregation of chain function, and is not what the OP's request.
Frank gave the good solution, as evidenced by...
SQL> ed Wrote file afiedt.buf 1 with t as (select to_date('16-Nov-11','DD-Mon-RR') as dt, 23 as col1, null as col2, null as col3, null as col4 from dual union 2 select to_date('17-Nov-11','DD-Mon-RR'), 12, null, null, null from dual union all 3 select to_date('18-Nov-11','DD-Mon-RR'), 321, null, null, null from dual union all 4 select to_date('19-Nov-11','DD-Mon-RR'), 23, null, null, null from dual union all 5 select to_date('20-Nov-11','DD-Mon-RR'), 132, null, null, null from dual union all 6 select to_date('16-Nov-11','DD-Mon-RR'), null, 2321, null, null from dual union all 7 select to_date('17-Nov-11','DD-Mon-RR'), null, 112, null, null from dual union all 8 select to_date('18-Nov-11','DD-Mon-RR'), null, 211, null, null from dual union all 9 select to_date('19-Nov-11','DD-Mon-RR'), null, 132, null, null from dual union all 10 select to_date('20-Nov-11','DD-Mon-RR'), null, 12, null, null from dual union all 11 select to_date('16-Nov-11','DD-Mon-RR'), null, null, 45, null from dual union all 12 select to_date('17-Nov-11','DD-Mon-RR'), null, null, 465, null from dual union all 13 select to_date('18-Nov-11','DD-Mon-RR'), null, null, 2123, null from dual union all 14 select to_date('19-Nov-11','DD-Mon-RR'), null, null, 132, null from dual union all 15 select to_date('20-Nov-11','DD-Mon-RR'), null, null, 65, null from dual union all 16 select to_date('16-Nov-11','DD-Mon-RR'), null, null, null, 456 from dual union all 17 select to_date('17-Nov-11','DD-Mon-RR'), null, null, null, 546 from dual union all 18 select to_date('18-Nov-11','DD-Mon-RR'), null, null, null, 4656 from dual union all 19 select to_date('19-Nov-11','DD-Mon-RR'), null, null, null, 566 from dual union all 20 select to_date('20-Nov-11','DD-Mon-RR'), null, null, null, 564 from dual) 21 -- 22 -- end of test data 23 -- 24 select dt 25 ,max(col1) as col1 26 ,max(col2) as col2 27 ,max(col3) as col3 28 ,max(col4) as col4 29 from t 30 group by dt 31* order by dt SQL> / DT COL1 COL2 COL3 COL4 ----------- ---------- ---------- ---------- ---------- 16-Nov-2011 23 2321 45 456 17-Nov-2011 12 112 465 546 18-Nov-2011 321 211 2123 4656 19-Nov-2011 23 132 132 566 20-Nov-2011 132 12 65 564 SQL>
-
Hello
I am using Oracle 11g, and I have a question about the following.
I have a table with the following data
Value of category name
AA 01 012
AA 02 63-123
BB 01 012
BB 02 63-114
03 55 BB
CC 01 088
DD 01 088
DD 02 63-145
03 65 DD
I need to extract the data in the following format
Name 01 02 03
AA 012 63-123
BB 012 55 63 - 114
CC 088
DD 088 65 63 - 145
How should I do for this?
I tried to use the wm_concat function, then using substr to extract each item, but the wm_concat function will extract some lines in the sequence (01,02,03) and other lines of the sequence (01,03,02). What can I do?
Thank you.SQL> -- generating sample data SQL> with t as ( 2 select 'AA' name, '01' category, '012' value from dual union 3 select 'AA', '02', '63-123' from dual union 4 select 'BB', '01', '012' from dual union 5 select 'BB', '02', '63-114' from dual union 6 select 'BB', '03', '55' from dual union 7 select 'CC', '01', '088' from dual union 8 select 'DD', '01', '088' from dual union 9 select 'DD', '02', '63-145' from dual union 10 select 'DD', '03', '65' from dual 11 ) 12 -- 13 -- actual query: 14 -- 15 select name 16 , max(decode(category, '01', value)) "01" 17 , max(decode(category, '02', value)) "02" 18 , max(decode(category, '03', value)) "03" 19 from t 20 group by name 21 order by name; NA 01 02 03 -- ------ ------ ------ AA 012 63-123 BB 012 63-114 55 CC 088 DD 088 63-145 65
-
Question about the correct use of the WM_CONCAT
Hello
I am trying to accomplish the following:
from this
and ends on thisENAME ---------- ADAMS ALLEN BLAKE ...
Basically, alphabetically sort the characters within each name. I have an intermediate step that seems promisingOLD_NAME NEW_NAME ---------- -------- ADAMS AADMS ALLEN AELLN BLAKE ABEKL ...
Yields aboveselect e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1);
the characters are in the right sequence, I thought that all I had to do was to use WM_CONCAT (and replace the comma it inserts with an empty string) and I would like to make. I thought it would do: (replacement of commas left out for clarity)OLDNAME NEWCHARPOS ---------- -------------------- ADAMS A ADAMS A ADAMS D ADAMS M ADAMS S ALLEN A ALLEN E ALLEN L ALLEN L ALLEN N BLAKE A BLAKE B BLAKE E BLAKE K BLAKE L ...
but the sequence of the newcharpos is messed up in the process and, rather than the expected result, I get this:select oldname, wm_concat(newcharpos) newname from ( select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1) ) group by oldname;
My question is, how to structure the last query so that the order of character as calculated in the inner query stays?OLDNAME NEWNAME ---------- -------------------- ADAMS A,S,M,D,A ALLEN A,N,L,L,E BLAKE A,L,K,E,B ...
Thank you for your help,
John.Or
SQL> select oldname, wm_concat(newcharpos) keep (dense_rank last order by null) newname from ( select e.ename oldname, substr(e.ename, iter.pos, 1) newcharpos from emp e, (select rownum pos from emp) iter where iter.pos <= length(e.ename) order by e.ename, substr(e.ename, iter.pos, 1) ) group by oldname / OLDNAME NEWNAME ---------- ------------------------------ ADAMS A,A,D,M,S ALLEN A,E,L,L,N BLAKE A,B,E,K,L CLARK A,C,K,L,R FORD D,F,O,R JAMES A,E,J,M,S JONES E,J,N,O,S KING G,I,K,N MARTIN A,I,M,N,R,T MILLER E,I,L,L,M,R SCOTT C,O,S,T,T SMITH H,I,M,S,T TURNER E,N,R,R,T,U WARD A,D,R,W 14 rows selected.
Or (11 GR 2)
SQL> select ename oldname, column_value newname from emp, xmltable(('string-join(for $i in (' || rtrim(regexp_replace(ename, '(.)', '"\1",'),',') || ') order by $i return $i, "")')) / OLDNAME NEWNAME ---------- ------------------------------ SMITH HIMST ALLEN AELLN WARD ADRW JONES EJNOS MARTIN AIMNRT BLAKE ABEKL CLARK ACKLR SCOTT COSTT KING GIKN TURNER ENRRTU ADAMS AADMS JAMES AEJMS FORD DFOR MILLER EILLMR 14 rows selected.
-
It is one of the use of "wm_sys.wm_concat" and imitate.create table workT(ID,Val) as select 1,'AAA' from dual union all select 1,'BBB' from dual union all select 1,'CCC' from dual union all select 1,'CCC' from dual union all select 1,'DDD' from dual union all select 2,'EEE' from dual union all select 2,'EEE' from dual union all select 2,'EEE' from dual union all select 2,'EEE' from dual union all select 2,'FFF' from dual union all select 2,'FFF' from dual union all select 2,'GGG' from dual;
However, I would like to know 'solution model', which is tablseScan only once.col conStr for a50 select ID,Val, wm_sys.wm_concat(Val) over(partition by ID order by Val) as conStr from workT select ID,aVal, substr(sys_connect_by_path(bVal,','),2) as conStr from (select a.ID,a.Val as aVal,b.Val as bVal, a.RowID as Row_ID, Row_Number() over(partition by a.RowID order by b.Val) as rn from workT a,workT b where a.ID = b.ID and a.Val >= b.Val) where connect_by_IsLeaf = 1 Start With rn=1 connect by prior rn+1 = rn and prior Row_ID = Row_ID order by ID,aVal; ID aVal conStr -- ---- --------------------------- 1 AAA AAA 1 BBB AAA,BBB 1 CCC AAA,BBB,CCC,CCC 1 CCC AAA,BBB,CCC,CCC 1 DDD AAA,BBB,CCC,CCC,DDD 2 EEE EEE,EEE,EEE,EEE 2 EEE EEE,EEE,EEE,EEE 2 EEE EEE,EEE,EEE,EEE 2 EEE EEE,EEE,EEE,EEE 2 FFF EEE,EEE,EEE,EEE,FFF,FFF 2 FFF EEE,EEE,EEE,EEE,FFF,FFF 2 GGG EEE,EEE,EEE,EEE,FFF,FFF,GGG
Can do us?
I supoose that we must use TableFunction.
I use Oracle10gR2.Hi Aketi,
OK, it is a little different. But it can be easily solved by using a function analytical max, like this:
SQL> create table workT(ID,Val) as 2 select 1,'AAA' from dual union all 3 select 1,'BBB' from dual union all 4 select 1,'CCC' from dual union all 5 select 1,'CCC' from dual union all 6 select 1,'DDD' from dual union all 7 select 2,'EEE' from dual union all 8 select 2,'EEE' from dual union all 9 select 2,'EEE' from dual union all 10 select 2,'EEE' from dual union all 11 select 2,'FFF' from dual union all 12 select 2,'FFF' from dual union all 13 select 2,'GGG' from dual 14 / Tabel is aangemaakt. SQL> select id 2 , rn 3 , substr(max(constr) over (partition by id,val),2) constr 4 from ( select * 5 from workt 6 model 7 partition by (ID) 8 dimension by(Row_Number() over(partition by ID order by Val) as rn) 9 measures(Val,cast(null as varchar2(50)) as conStr) 10 rules 11 ( conStr[any] order by rn = conStr[cv()-1] || ',' || Val[cv()] 12 ) 13 ) 14 / ID RN CONSTR ---------- ---------- -------------------------------------------------- 1 1 AAA 1 2 AAA,BBB 1 3 AAA,BBB,CCC,CCC 1 4 AAA,BBB,CCC,CCC 1 5 AAA,BBB,CCC,CCC,DDD 2 1 EEE,EEE,EEE,EEE 2 4 EEE,EEE,EEE,EEE 2 3 EEE,EEE,EEE,EEE 2 2 EEE,EEE,EEE,EEE 2 5 EEE,EEE,EEE,EEE,FFF,FFF 2 6 EEE,EEE,EEE,EEE,FFF,FFF 2 7 EEE,EEE,EEE,EEE,FFF,FFF,GGG 12 rijen zijn geselecteerd.
Kind regards
Rob. -
You place your order on the Apple Site
I ordered a 7 IPhone September 21, as it was very
hard to get one at the store here in Rome, Italy
at that time. Today, 7 October, I see that the IPhone is available to any
store, but I have still not received my... and shipping follow-up shows that
the phone is always located in Amsterdam, Holland. This means that it will be
probably need another 7 days to be delivered to me! Now, I want to only disclose my
concern that I think that what makes an online prescription should be advantaged
otherwise it's not really a reason to buy
an article on the Web Site!And this is the last time I'll do so!
Thank you!
Greetings from Rome
!
Don't know what your question on the iTunes Store, but you already know that you talk only to other users on these forums and that Apple are not here - if you want to contact Apple using the 'contact us' link at the bottom right of each page here.
-
Change order number/special character artists
I would like to know if there is a way to change the order of all the artists that begin with a number or a special character order. Currently, they are all sitting at the bottom of the list of the artist on the ipod (and iTunes) but I would like to have all displays at the top of this list.
This is the sort order... I think you would need to change the names of the artists so that they start with something that gets sorted at the top of the list in alphanumeric order. For example, replace 10,000 Maniacs a_10, 000 Maniacs.
-
My photos and videos are not in chronological order, when I export the Photos app
Hello. When I export my photos and videos from the Photos app on my iMac all the photos and videos are not in order. I need all the photos in good standing - I need to export about 5 000 pictures of the application in order for a meeting next week! Help, please!
Ethan.
This is not photo - it is a function of the viewing program (probably the finder) - once the photos are exprted form pictures you can see then in different ways which you control, Photos does not - by the finder you can view by name of son, byt several dates, by file size, etc.
Usually, the best way to accomplish what you want is to export using the names of batch file numbeing and then sort by file name in the program viewing
LN
-
Impossible to place an order unlock iPhone 7 over 256 GB silver color online
I can't unlock iPhone ordering 7 more than 256 GB silver color online. Also, I checked with my ISP (AT & T) in the store. Update received saying pre-paid AT & T customer can't place an order for me. And suggested I check in the Apple store. Please suggest me without contract, how to buy iphone 7 more
Today, I visited the Apple store. Representative informed me that they cannot place an order for customer prepaid with any carrier (AT & T or T-mobile) even if you are willing to pay the total amount in advance.
-
I go the iphone7 order + 19/9
and he said: it will be delivery between 11/10-17/10
but the State of the process is still in its housing on part of treatment about two weeks
they will be actually delivered between the date or not?
They should be. Mine was stuck in the treatment of a week and a half, and shipping and final delivery arrived within 5 days after that State passed preparing to ship.
-
CAN I change the order on my MacBook Air when my phone is connected (but the changes are not published on my phone)
Hello, wolfebait!
Welcome to congratulations on getting a new iPhone and Apple support communities 7. I see your message that you are having problems changing the order of song into playlists that you created, but it only happens on your new iPhone. I have several playlists I created myself, and I sometimes have to change the order of songs as well. I'm happy to help you with this.
- Open your music app.
- Type library on the bottom left.
- Touch Playlists.
- Press the Playlist you want to change (it must be one that you have created, as organized playlists cannot be changed).
- Press 'Edit' at the top right of your screen.
- You should now see red circles 'remove' to the left of each song and three horizontal lines gray right of each song.
- Press the grey horizontal lines with your finger and drag the song to the position in the playlist that you want it to be in.
- When you have finished editing, type "Done" in the upper right corner.
- Your playlist should now be in the new order that you chose!
Have a great rest of your week!
Maybe you are looking for
-
500 - Lenovo Yoga OLD BIOS file 15IBD
Hi, I have a problem with the keyboard on my 500 Yoga where some keys do not work as they should. It is not a Windows problem and I could do with an older version of BIOS by train. Can anyone provide the previous BIOS version file to BDCN63WW.cap for
-
Can I have two AppleID on my iPad
Is it possible to have two Apple ID for an iPad, for example, one for a company AppleID used to track the location of the device via find my iPad app and a personal AppleID for purchase / installation / update of Apps? IPads have been initially confi
-
What is the Ci service?Can someone tell me where to get the information to find out what that all abbreviations in 'Source' in the case where the viewer areThank you to everyone.
-
It all started yesterday, restarted and began to Today it won't go away, run in safe mode It's the Event Viewer error Event type: errorEvent source: crypt32Event category: noEvent ID: 11Date: 01/01/2005Time: 10:23:06User: n/aComputer: THESIMPSONSOFTO