QUERY- combine 2 rows into 1 row
Hello,
I need help with writing SQL command.
I have 2 tables:
T1:(colA)
10
20
30
T2: (ColA, ColB)
10 1
10 2
20 1
30 2
30 3
I want the result to be like following:
10 1,2
20 1
30 2,3
Is that possible?
thank you very much for your help.
Hello,
I need help with writing SQL command.
I have 2 tables:
T1:(colA)
10
20
30
T2: (ColA, ColB)
10 1
10 2
20 1
30 2
30 3
I want the result to be like following:
10 1,2
20 1
30 2,3
Is that possible?
thank you very much for your help.
Similar Messages
-
How to combine many rows into one row
Hi all,
I have a question regarding to how to combine many rows into one row?
My result set is like that:
ITEM_NO NAME1
11 abc
11 cde
11 fg
Want to combine them into
ITEM_NO NAME1
11 abc;cde;fg
would anybody can tell me how to do that? Thanks
RayYou can check this --
satyaki>
satyaki>
satyaki>create table t
2 as
3 select 11 ITEM_NO, 'abc' NAME1 from dual
4 union all
5 select 11 ITEM_NO, 'cde' NAME1 from dual
6 union all
7 select 11 ITEM_NO, 'fg' NAME1 from dual;
Table created.
satyaki>
satyaki>
satyaki>
satyaki>set lin 10
satyaki>
satyaki>desc t;
Name Null? Type
ITEM_NO NUMBER
NAME1 VARCHAR2(3)
satyaki>
satyaki>
satyaki>set lin 1000
satyaki>
satyaki>
satyaki>
satyaki>SELECT ITEM_NO,
2 LTRIM(MAX(SYS_CONNECT_BY_PATH(NAME1,';'))
3 KEEP (DENSE_RANK LAST ORDER BY curr),';') AS NAME1_DET
4 FROM (SELECT ITEM_NO,
5 NAME1,
6 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) AS curr,
7 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) -1 AS prev
8 FROM t)
9 GROUP BY ITEM_NO
10 CONNECT BY prev = PRIOR curr AND ITEM_NO = PRIOR ITEM_NO
11 START WITH curr = 1;
ITEM_NO NAME1_DET
11 abc;cde;fgRegards.
Satyaki De. -
How to combine many rows into 1 rows in 1 column?
Hi all,
I have a question regarding to how to combine many rows into one row?
My result set is like that:
ITEM_NO NAME1
11 abc
11 cde
11 fg
Want to combine them into
ITEM_NO NAME1
11 abc;cde;fg
would anybody can tell me how to do that? Thanks
RayHi,
select * from x2;
INO NAME
13 PQR
11 ABC
11 DEF
12 JKL
12 MNO
11 GHI
select p.ino as ITEMNO,
substr(max(substr(sys_connect_by_path (p.name,';'),2)),1,60) as ITEMNAME
from (select ino,name,
row_number()over (partition by ino order by ino, name) rn
from x2) p
start with p.rn = 1
connect by p.rn = prior p.rn + 1
and prior p.ino = p.ino
group by ino;
OP
ITEMNO ITEMNAME
11 ABC;DEF;GHI
12 JKL;MNO
13 PQR cheers
Nirmal -
Combine 2 rows into single row?
I have a table A which has information related to a process. For process completion there exist 2 rows. One has in it the total elapsed time, the time the entire process (which is multipart) begin and end time, but the columns related to rows processed are blank. Another related row has a start, end and elapsed time in it -- which I don't want -- but it has the row counts that I do want.
I want to take these 2 rows, combine the relevant information into 1 row and insert that row into table B.
I know I could insert from the first row and then come back and update it from the second row, but I hate having to read Table A twice. Any suggestions?Hello
Is it not just a matter of using group by with sum? I may well have missed an important detail but here's a starting point:
SQL> CREATE TABLE DT_TEST_PROCESS
2 ( id number,
3 stage number,
4 rows_processed number,
5 elapsed number
6 )
7 /
Table created.
SQL>
SQL> INSERT INTO dt_test_process
2 VALUES(1,1,100,0)
3 /
1 row created.
SQL> INSERT INTO dt_test_process
2 VALUES(1,2,0,10)
3 /
1 row created.
SQL> INSERT INTO dt_test_process
2 VALUES(2,1,1000,0)
3 /
1 row created.
SQL> INSERT INTO dt_test_process
2 VALUES(2,2,0,20)
3 /
1 row created.
SQL>
SQL> INSERT INTO dt_test_process
2 VALUES(3,1,500,0)
3 /
1 row created.
SQL> INSERT INTO dt_test_process
2 VALUES(3,2,0,30)
3 /
1 row created.
SQL>
SQL> SELECT
2 id,
3 SUM(rows_processed) total_rows,
4 SUM(elapsed) total_elapsed
5 FROM
6 dt_test_process
7 GROUP BY
8 id
9 /
ID TOTAL_ROWS TOTAL_ELAPSED
1 100 10
2 1000 20
3 500 30
SQL>
SQL> CREATE TABLE dt_test_process_sum AS
2 SELECT
3 id,
4 SUM(rows_processed) total_rows,
5 SUM(elapsed) total_elapsed
6 FROM
7 dt_test_process
8 GROUP BY
9 id
10 /
Table created.HTH
David -
How to combine 2 table rows into 1
Hi,
I have an interesting situation where I have two table rows which represent the same row but with a different set of attributes, and I want to combine these two rows into one row for display with in my ADF table. Is there a way that I can manipulate my table data to do this before it is rendered within my table?
As an example I have:
Name | Type | Attribute
T1 A blue
T1 A red
T2 B green
Instead of displaying the above I would like to display
Name | Type | Attribute
T1 A blue, red
T2 B greenAny help is appreciated,
-Wraith
Edited by: wraith101 on Oct 8, 2012 2:42 PMFrank,
create a database view that calls a stored function to parse the duplicate values into a comma separate string and then built the ADF BC entity and view on top of this. This issue is not really one that should be fixed on the >model or UI layer. Building entity view is not a good idea, as all views are not update able, and in this scenario it would'nt be. -
Concatenation Multiple Rows into Single Row
My select query is like wise
ID Name
1 Arthi
2 Preethi
3 Madhu
4 Saranya
Above i listed all the names using the select query. Now i have to combine this 4 rows in single row like
Arthi,Preethi,Madhu,Saranya.
Also this rows may be 5 or 50 too. So what are Names listed using select statement those should combine into one Single String.
Help me plPlease post this in an appropriate forum;
SQL and PL/SQL
PL/SQL
Community Feedback and Suggestions (Do Not Post Product-Related Questions Here)
Adith -
Hi friends,
I have one table like:
10 SAM
10 CAN
10 MAN
10 DEV
20 MAL
And want output like:
10 SAM,CAN,MAN,DEV
20 MAL
i want to combine multiple rows into one within an existing view.
What query will suit this to get this type of output.Please refer to this thread
column values separated by , -
How To Concatenate Column Values from Multiple Rows into a Single Column?
How do I create a SQL query that will concatenate column values from multiple rows into a single column?
Last First Code
Lesand Danny 1
Lesand Danny 2
Lesand Danny 3
Benedi Eric 7
Benedi Eric 14
Result should look like:
Last First Codes
Lesand Danny 1,2,3
Benedi Eric 7,14
Thanks,
David JohnsonStarting with Oracle 9i
select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
from
(select last, first, code, row_number() over(partition by last, first order by code) rn
from a)
connect by last = prior last and first = prior first and prior rn = rn -1
start with rn = 1
group by last, first
LAST FIRST CODES
Lesand Danny 1,2,3
Benedi Eric 7,14Regards
Dmytro -
Need help with turning multiple rows into a single row
Hello.
I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
My situation:
I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
select jiraissue.id, pkey, reporter, summary
,changegroup.created change_dt
,dbms_lob.substr(changeitem.newstring,15,1) change_type
,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
from jiraissue
,changeitem, changegroup
,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
where jiraissue.project = 10110
and jiraissue.issuetype = 51
and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
and phaseinfo.issue = jiraissue.id
and changeitem.groupid = changegroup.id
and changegroup.issueid = jiraissue.id
order by jiraissue.id,change_dt
Results:
1 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 9:30:38 AM Open 1
2 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 11:37:02 AM Testing 2
3 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-06-08 9:14:52 AM Closed 3
4 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:37 AM Open 4
5 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:42 AM Open 5
6 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:50 AM Testing 6
7 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:53 AM Closed 7
8 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-10-03 10:26:21 AM Open 1
9 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-11-17 9:39:39 AM Testing 2
10 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2011-02-02 6:18:02 AM Closed 3
11 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2008-09-29 2:44:54 PM Open 1
12 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2010-05-29 4:47:37 PM Blocked 2
13 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:14:57 AM Open 3
14 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:32 AM Testing 4
15 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:47 AM Closed 5Hi,
Welcome to the forum!
StblJmpr wrote:
... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
CREATE TABLE changegroup
( issueid NUMBER
, created DATE
, id NUMBER
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'), 30);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
CREATE TABLE changeitem
( groupid NUMBER
, newstring VARCHAR2 (10)
INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
ISSUEID HISTORY
21191 Open (0) >> Testing (692) >> Closed
23234 Open (45) >> Testing (807) >> Closed
23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
"The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
The database is 10.2.0.4That's very important. Always post your version, like you did.
Here's one way to get those results from that data:
WITH got_order_row AS
SELECT cg.issueid
, LEAD (cg.created) OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
- cg.created AS days_in_stage
, ROW_NUMBER () OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
) AS order_row
, ci.newstring AS change_type
FROM changegroup cg
JOIN changeitem ci ON cg.id = ci.groupid
WHERE ci.newstring IN ( 'Blocked'
, 'Closed'
, 'Testing'
, 'Open'
-- AND ... -- any other filtering goes here
SELECT issueid
, SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
WHEN CONNECT_BY_ISLEAF = 0
THEN ' ('
|| ROUND (days_in_stage)
|| ')'
END
, ' >> '
, 5
) AS history
FROM got_order_row
WHERE CONNECT_BY_ISLEAF = 1
START WITH order_row = 1
CONNECT BY order_row = PRIOR order_row + 1
AND issueid = PRIOR issueid
AND PRIOR change_type != 'Closed'
ORDER BY issueid
;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary. -
Help in inserting rows into a table
I have a table called acct_fact,
I need to insert rows in the table using a script but the problem is there's a column called seq_nbr which has random seq nbr of 14character length like 'ZWX98MGD9MVAD6J','ZWX98MG67RVAD6J' etc.,
While inserting rows I need to generate such seq_nbr for those columns and insert rows into the table, can I use any such mechanism in my insert query to insert such random nbr's while inserting rows into a table.
If so please suggest meHi Peter,
Thankyou for the quick reply:)
can you suggest me how to implement it here in my script snippet:
while read var_acct_nbr
do
echo "update acct_attr set acct_attr_exp_dt ='$ExpDate' where Acct_Attr_Value_Text='15' and acct_attr_exp_dt is null and person_id='LDCarrBillAgrm' and acct_nbr='$var_acct_nbr' ;" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
echo "insert into acct_fact values ('$var_acct_nbr','$ExpDate','$ExpTime','*seq_nbr*','N','ProjTereza','Remoção de acordo d; data de expiração: $ExpDate',null,'1','LDE',null);" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
done < ./$DirectoryName/ExpireAccts_$TimeStamp.LOG
the script takes each acct_nbr nbr form a input file and fires an insert statement.
The one in bold is the column where such sequence need to be inserted.can you help me in implementing the way you suggested in my script i.e., insert statement
Thanks in Advance:)
Edited by: rkrish on Jun 27, 2012 3:04 AM -
List aggregate two rows into one
query :
select kod_negeri.NAMA kod_negeri_nama,
hakmilik.id_hakmilik,
MOHON.PENYERAH_NAMA,
MOHON.PENYERAH_ALAMAT1, MOHON.PENYERAH_ALAMAT2, MOHON.PENYERAH_ALAMAT3,
MOHON.PENYERAH_ALAMAT4, MOHON.PENYERAH_POSKOD, MOHON.PENYERAH_KOD_NEGERI,
MOHON.PENYERAH_NO_RUJ, MOHON.ID_MOHON, HAKMILIK.KOD_HAKMILIK, HAKMILIK.NO_HAKMILIK,
KOD_LOT.NAMA, HAKMILIK.NO_LOT, KOD_BPM.NAMA, KOD_DAERAH.NAMA,
LELONG.TMPT, LELONG.DIMASUK, PGUNA.NAMA,
PIHAK.ALAMAT1, pihak.NAMA ven,
PIHAK.ALAMAT2, PIHAK.ALAMAT3, PIHAK.ALAMAT4, PIHAK.POSKOD,
mohon.id_mohon ,
pguna.NAMA pguna_nama,
pguna.JAWATAN,
kod_daerah.NAMA kod_daerah_nama,
to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,
to_char(lelong.TRH_lelong,'DD')||' '|| to_char(lelong.trh_lelong,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_lelong, 'YYYY') trh_le,
to_char(lelong.trh_lelong, 'Day') day,
to_char(lelong.TRH_lelong,'HH12:MI ') hour,
DECODE(SUBSTR(to_char(lelong.TRH_lelong,'HH12:MI AM'),-2,2),'AM','Petang','pagi') noon,
enkuiri.cara_lelong,
lelong.TMPT,
lelong.HARGA_RIZAB,
enkuiri.harga_rizab,
initcap(pihak.NAMA) pihak_nama,
initcap(lelong.EJA_RIZAB) er,
'RM'||enkuiri.TUNGGAK_AMAUN,
lelong.DEPOSIT,
convert_number_words(lelong.DEPOSIT) as converted_form,
to_char(lelong.TRH_AKHIR_BYR,'DD')||' '|| to_char(lelong.TRH_AKHIR_BYR,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_AKHIR_BYR, 'YYYY') TRH_AKHIR_BYR,
to_char(sysdate,'DD') ||' '|| to_char(sysdate,'MONTH','nls_date_language=malay') ||' '||to_char(sysdate,'yyyy') sysd,
kod_bpm.NAMA kod_bpm_nama,
kod_lot.NAMA kod_lot_nama,
hakmilik.NO_LOT,
hakmilik.KOD_HAKMILIK,
hakmilik.NO_HAKMILIK
from
mohon ,
mohon_hakmilik ,
lelong ,
pguna ,
pihak ,
kod_daerah ,
enkuiri ,
kod_bpm ,
hakmilik ,
kod_lot ,
kod_negeri,
mohon_fasa ,
kod_hakmilik
WHERE mohon.id_mohon = mohon_hakmilik.id_mohon and
mohon_hakmilik.id_hakmilik = hakmilik.id_hakmilik and
hakmilik.kod_hakmilik = kod_hakmilik.kod(+) and
hakmilik.kod_lot = kod_lot.kod(+) and
hakmilik.kod_bpm = kod_bpm.kod(+) and
hakmilik.kod_daerah = kod_daerah.kod(+) and
mohon.id_mohon = enkuiri.id_mohon and
lelong.id_pihak = pihak.id_pihak and
lelong.id_mh = mohon_hakmilik.id_mh and
pihak.kod_negeri = kod_negeri.kod(+) and
mohon.id_mohon = mohon_fasa.id_mohon and
mohon_fasa.id_aliran ='semakan' and
mohon_fasa.id_pguna = pguna.id_pguna and
mohon.id_mohon = :p_id_mohon
and enkuiri.KOD_STS='AK'
and mohon.id_mohon ='0405AUC2010007436'KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM,151,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
,050540HSD00022923,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,HSD,22923,Lot,0009838,Mukim Jimah,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,no2,Ali Bin Abudillah,jalan 3,taman permata,lorong mentari,32333,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ali Bin Abudillah,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Jimah,Lot,0009838,HSD,22923
KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM and HSD,151 and 22923,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
that means i need to list aggregate the two rows into one how to make the changes for the above query in order to do so .
Edited by: user9093689 on Feb 9, 2011 10:03 PMuser9093689 wrote:
now need to bother abt this that line converts date into malay language
to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,iam retriving two rows of output, wat i need is to display one row and the second row values which are not similar should be added to the first row
for example for column
kod_hakmilik two rows values are
PM
HSD
but they should be display as
PM and HSD
finally my aim is to retrieve only one row as output.
i dont how exactly the term listaggr . how ever it may be whether using groupby or any other but the output should be as aboveWhat version of Oracle are you on?
Look up the LISTAGG() function in the documentation for your version (assuming it is there) and see if it can do what you want -
How to display the rows in to columns and columns into rows?
DES:- I know by using pivot and unpivot you can convert rows into columns and columns into rows but i don't know how to write the syntax?
Hi,
Besides the places Martin mentioned above, there are many examples in the forum FAQ:
https://community.oracle.com/message/9362005#9362005
For an example of both PIVOT and UNPIVOT in the same query, see
http://forums.oracle.com/forums/thread.jspa?threadID=920854&tstart=0 -
How do I get rid of 'Warning: Query has exceeded 200 rows...' message
Hi there,
I have a custom page to query our Inventory details. I display 100 rows on the page. I noticed today I can hit next once and then I get the message 'Query has exceeded 200 rows. Potentially more rows exist, please restrict your query'. If I try to Export this data using an Export to Excel button, it gives me the message 'There is no data to export'.
I am EXTREMELY new to OAF...is there a property or something somewhere that I can change to fix this? We will have potentially 100s of thousands of records to display and export, so 200 simply is not acceptable.
We are on ATG RUP7, 11.5.10.2. This is a completely custom page, pulling from custom tables. Please let me know if any other information is needed.
Thanks,
Janelanasazii wrote:
Thanks, Shailendra!I am glad it worked, Thanks for the point Janel. :)
That seems to work for when I run the page through the iSupplier portal. However I noticed during development when I am testing the page on my computer, I am still getting this message? Is there anyway to get rid of it on the client side? I assume that profile is set correctly on the development instance which you are using from JDEV.
Sometimes you need apache bounce to make sure the profile option change come into effect.
So do a apache bounce.
Thanks
Shailendra
>
Thanks,
Janel -
Converting Rows into Column in Oracle 10g
Hi All,
I m using Oracle Version 10.1.0.2.0 - Production
I have requirement to convert rows into column wise as per the following:
My Query is:
WITH t
AS ( SELECT 'A' AS x, 100 AS y FROM DUAL
UNION ALL
SELECT 'B',200 FROM DUAL
SELECT X, Y
FROM t;
X Y
A 100
B 200
My Requirement is
A B
100 200
So any one could help me that how I resolve this.
Regards,
PrasantaDear frank,
Thanks for your support,.
It's working fine for static cases.If the first column is dynamic then how come i will resolve it.
Example:
Create table mytab (ID_C Varchar2(15),Value_N Number);
Records Population into MyTab table is dynamic.
Insert into mytab values('HO',5000);
Insert Into mytab values('PG1',2400);
Insert Into mytab values('PG2',3000);
Insert Into mytab values('PG3',800);
Commit;
SQL> Select * From MyTab;
IDC_ ValueN_
HO 5000
PG1 2400
PG2 3000
PG3 800
Then My expected result will be as follows
HO PG1 PG2 PG3
5000 2400 3000 800
Thanks and Regards,
Prasanta -
Tranforming columns into rows taking to long
Hi,
Please help me in tuning the query. I am trying to transform rows into columns. Its taking lots of time almost 13hrs for 500k records.
select
decode ( r,
1,Col_1,
2,Col_2,
3,Col_3,
4,Col_4,
5,Col_5,
6,Col_6,
7,Col_7,
8,Col_8,
9,Col_9,
10,Col_10,
11,Col_11,
12,Col_12,
13,Col_13,
14,Col_14,
15,Col_15,
16,Col_16,
17,Col_17,
18,Col_18,
19,Col_19,
20,Col_20) Col,
R ,
decode ( r,
1,CASE WHEN SUBSTR(T1.Date_1,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_1,'YYYYDDD') ELSE NULL END,
2,CASE WHEN SUBSTR(T1.Date_2,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_2,'YYYYDDD') ELSE NULL END,
3,CASE WHEN SUBSTR(T1.Date_3,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_3,'YYYYDDD') ELSE NULL END,
4,CASE WHEN SUBSTR(T1.Date_4,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_4,'YYYYDDD') ELSE NULL END,
5,CASE WHEN SUBSTR(T1.Date_5,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_5,'YYYYDDD') ELSE NULL END,
6,CASE WHEN SUBSTR(T1.Date_6,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_6,'YYYYDDD') ELSE NULL END,
7,CASE WHEN SUBSTR(T1.Date_7,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_7,'YYYYDDD') ELSE NULL END,
8,CASE WHEN SUBSTR(T1.Date_8,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_8,'YYYYDDD') ELSE NULL END,
9,CASE WHEN SUBSTR(T1.Date_9,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_9,'YYYYDDD') ELSE NULL END,
10,CASE WHEN SUBSTR(T1.Date_10,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_10,'YYYYDDD') ELSE NULL END,
11,CASE WHEN SUBSTR(T1.Date_11,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_12,'YYYYDDD') ELSE NULL END,
12,CASE WHEN SUBSTR(T1.Date_12,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_12,'YYYYDDD') ELSE NULL END,
13,CASE WHEN SUBSTR(T1.Date_13,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_13,'YYYYDDD') ELSE NULL END,
14,CASE WHEN SUBSTR(T1.Date_14,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_14,'YYYYDDD') ELSE NULL END,
15,CASE WHEN SUBSTR(T1.Date_15,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_15,'YYYYDDD') ELSE NULL END,
16,CASE WHEN SUBSTR(T1.Date_16,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_16,'YYYYDDD') ELSE NULL END,
17,CASE WHEN SUBSTR(T1.Date_17,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_17,'YYYYDDD') ELSE NULL END,
18,CASE WHEN SUBSTR(T1.Date_18,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_18,'YYYYDDD') ELSE NULL END,
19,CASE WHEN SUBSTR(T1.Date_19,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_19,'YYYYDDD') ELSE NULL END,
20,CASE WHEN SUBSTR(T1.Date_20,5) BETWEEN '001' AND '366'
THEN TO_DATE(T1.Date_20,'YYYYDDD') ELSE NULL END)
Date from Table_1 t1,(select level R from dual connect by level <= 20)
where decode ( r,
1,Col_1,
2,Col_2,
3,Col_3,
4,Col_4,
5,Col_5,
6,Col_6,
7,Col_7,
8,Col_8,
9,Col_9,
10,Col_10,
11,Col_11,
12,Col_12,
13,Col_13,
14,Col_14,
15,Col_15,
16,Col_16,
17,Col_17,
18,Col_18,
19,Col_19,
20,Col_20) !=0
thanks
Edited by: user627047 on Jun 23, 2009 12:07 AMHere I managed to get the output
PLAN_TABLE_OUTPUT
Plan hash value: 2442671038
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 408 | 274K| 40 (43)| 00:00:01 |
| 1 | NESTED LOOPS | | 408 | 274K| 40 (43)| 00:00:01 |
| 2 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
|* 3 | CONNECT BY WITHOUT FILTERING| | | | | |
| 4 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 5 | EXTERNAL TABLE ACCESS FULL | EVP0010 | 408 | 269K| 38 (45)| 00:00:01 |
Predicate Information (identified by operation id):
3 - filter(LEVEL<=20)
5 - filter(DECODE("R",1,"C_LOGO_LYLTY_CARD_1",2,"C_LOGO_LYLTY_CARD_2",3,"C_LOGO
_LYLTY_CARD_3",4,"C_LOGO_LYLTY_CARD_4",5,"C_LOGO_LYLTY_CARD_5",6,"C_LOGO_LYLTY_CAR
D_6",7,"C_LOGO_LYLTY_CARD_7",8,"C_LOGO_LYLTY_CARD_8",9,"C_LOGO_LYLTY_CARD_9",10,"C
_LOGO_LYLTY_CARD_10",11,"C_LOGO_LYLTY_CARD_11",12,"C_LOGO_LYLTY_CARD_12",13,"C_LOG
O_LYLTY_CARD_13",14,"C_LOGO_LYLTY_CARD_14",15,"C_LOGO_LYLTY_CARD_15",16,"C_LOGO_LY
LTY_CARD_16",17,"C_LOGO_LYLTY_CARD_17",18,"C_LOGO_LYLTY_CARD_18",19,"C_LOGO_LYLTY_
CARD_19",20,"C_LOGO_LYLTY_CARD_20")<>0)
24 rows selected. -
How to convert row into column
Hi All,
My oracle apps version is r12 and db is 10 and i am using Bi publisher version 10g.
Is it possible to convert row into column in Rtf template,
My Query is
SELECT distinct pvs.vendor_site_code,sum(aia.invoice_amount)
FROM ap_invoices_all aia, po_vendors po, po_vendor_sites_all pvs
WHERE aia.org_id = pvs.org_id
AND aia.vendor_id = po.vendor_id
AND aia.vendor_site_id = pvs.vendor_site_id
AND aia.org_id=204
group by pvs.vendor_site_code
And output is like this
Vendor sitecode Invoiceamt
EAM-ERS 79240
STAR GATE - PAY 3245902.31
UPS - HQ 10792040.9
Like this
So in template i need the output like this
Vendor sitecode EAM-ERS STAR GATE - PAY UPS - HQ
Invoiceamt 79240 3245902.31 10792040.9
I tried to achieve the output using sql query but by hardcoding only i have achieved it, so i have tried to convert directly in RTF template.
can any one tell me is it possible.
And if new project is added from the front end ie(now the query will produce 4 rows but now in template i have created only three columns)
Is it possible to add a new column dynamically.
Can any one please guide me and tell me is there any example.
Thanks & regards
SrikkanthTake a look at this post: http://blogs.oracle.com/roller-ui/bsc/spider.jsp?entry=MT%3aENTRY%3a5001
Thanks,
Bipuser
Maybe you are looking for
-
Get current date in mm/dd/yyyy format
Need to get todays date in the format mm/dd/yyyy and store it in a database by using JDBC API ..how to convert Date given by Date() to the format mmdd/yyyy .The column type of the table whr date has to be inserted is of Type Date/Time (Microsoft Acce
-
Next chapter isn't working from the remote control (Adobe Encore)
Hi, Encore CS5 My project starts with the main menu -Film1 -Film2 -Film3 -Chapters All my film1, film3, film3 have chapters and we can access to each capter properly from the chapters menus. BUT : Film1 & Film2 --> the next and Prev button of the rem
-
Error when registering potential supplier in the SUS client
Dear experts, We have configured the supplier qualification process in SRM We are on SRM 7 EhP1. Customizing switch SRM_701_SUCO_SUP_REG is active We have set up SUS in a seperate client than SRM. When trying to register a potential supplier I'm gett
-
How can i refresh my 5s that erase all its content to factry reset
I tried to reset my 5s they asked me pascode in typed 0000 its my pascode then it again asked me pascode i retyped it never hapened before well i retyoed it says incorect in redbar i tried few atempts the jt says try after 5 minuts then 15 then 60 mi
-
Connectivity 5.1 to ddts-100
Can ne one help me? I got the decoder since last 20 days. Not getting the sound effects the way i wanted it. I m haivng philips 5.1 sonic edge sound card (psc605), and 5.1 inspire 5200 creative speakers and got new ddts-100. When i connect ddts-100 t