Converting rows to coloumns
hi to all
i am working on generating reports from database
the query is
i have to write query to retrive 36 coloumns from database where
16 coloumns reside in a single table and remaining 20 coloumns are in another table in the form of rows which are to be converted into coloumns please any one help me on this .......... but have to do this with out reducing the performance if any idea please post as soon as possible
thanks in advance
Edited by: user13061827 on Apr 30, 2010 4:24 AM
jiraissue table coloumns
ID
PKEY
PROJECT
REPORTER
ASSIGNEE
ISSUETYPE
SUMMARY
DESCRIPTION
ENVIRONMENT
PRIORITY
RESOLUTION
ISSUESTATUS
CREATED
UPDATED
DUEDATE
VOTES
TIMEORIGINALESTIMATE
TIMEESTIMATEKey
JIRA CUSTOMFIELDVALUE TABLE COLOUMNS
ID ISSUE customfield values
84472240 2683160 10284 gr
84472241 2683160 10428 63185452
84472242 2683160 10325 18-03-10
84472243 2683160 10329 Austria
84472244 2683160 10023 gouri shankar
84472245 2683160 10024 56
84472246 2683160 10027 11-03-10
84472247 2683160 10274 sql
84472248 2683160 10337 0-30
84472249 2683160 10421 66956
84472250 2683160 10420 2000
84472251 2683160 10323 14-03-10
84472252 2683160 10321 01-03-10
84472253 2683160 10320 IOH
84472254 2683160 10050 484
84472255 2683160 10073 efwefww
84472256 2683161 10284 gre
84472257 2683161 10428 2
84472258 2683161 10325 14-03-10
84472259 2683161 10329 Belgium
84472260 2683161 10023 amrutam
84472261 2683161 10024 223656
84472262 2683161 10027 04-03-10
84472263 2683161 10274 star
84472264 2683161 10337 31-60 Project
84472265 2683161 10421 256
84472266 2683161 10420 1910
84472267 2683161 10323 13-03-10
84472268 2683161 10321 12-03-10
84472269 2683161 10320 MQE
84472270 2683161 10050 2
84472271 2683161 10073 1421
84472272 2683162 10284 ss Updated
Affects VSummary
Issuetype
OUTPUT COLOUMNS
Project
Key
Summary
Issuetype
Status
Priority
Resolution
Assignee
Reporter
Created
Updated
Affects Version/S
Fix Version/S
Component
Duedate
Images
Original
Estimate
Remainingestimate
Time Spent
Work Ratio
IssueLinks
Environment
Description
Security Level Progress
Cleared Date Project
Key
Summary
Issuetype
Status
Priority
Resolution
Assignee
Reporter
Created
Updated
Affects Version/S
Fix Version/S
Component
Duedate
Images
Original
Estimate
Remainingestimate
Time Spent
Work Ratio
IssueLinks
Environment
Description
Security Level Progress
Cleared Date
Email
Release Date
Country
Z#dpl#
Error Type
To
Date Of First Response
Resolution Date
Z#debitbalanceact#
Z#clearedinsource#
Bcc
Payment Method
Cc
From
Subject
Message
Description
Email
Release Date
Country
Z#dpl#
Error Type
To
Date Of First Response
Resolution Date
Z#debitbalanceact#
Z#clearedinsource#
Bcc
Payment Method
Cc
From
Subject
Message
Description
IN CUSTOMFIELD VALUE EACH CUSTOMFIELD NO REPRESENTS A COLOUMN
Edited by: user13061827 on Apr 30, 2010 5:06 AM
Edited by: user13061827 on Apr 30, 2010 5:07 AM
Edited by: user13061827 on Apr 30, 2010 5:08 AM
Edited by: user13061827 on Apr 30, 2010 5:11 AM
Similar Messages
-
CONVERT ROWS INTO COLUMNS IN INTERNAL TABLE
Hi Experts,
I want to convert rows into coloumns in final internal table.
How to do that one. Can any one help me its very urgent.
Regards,
PBS.hi,
Find the below code for changing rows into colums.
data: begin of itab1 occurs 0,
fld,
end of itab1.
data: begin of itab2 occurs 0,
fld1,
fld2,
fld3,
end of itab2.
itab1-fld = 1.
append itab1.
itab1-fld = 2.
append itab1.
itab1-fld = 3.
append itab1.
read table itab1 index 1.
if sy-subrc eq 0.
itab2-fld1 = itab1-fld.
endif.
read table itab1 index 2.
if sy-subrc eq 0.
itab2-fld2 = itab1-fld.
endif.
read table itab1 index 3.
if sy-subrc eq 0.
itab2-fld3 = itab1-fld.
endif.
append itab2.
loop at itab1.
write:/ itab1.
endloop.
loop at itab2.
write:/ itab2.
endloop.
refer the below link for further information
internal table rows to columns
in the final display list how can i change rows to columns and vice versa -
Query to convert Row to column - Re-posting
Hi all,
i am re-posting the same requirement, please do the needful.
I need a query to convert row value into column delimited by ','
create table tb_row_2_col (id number,val varchar2(100));
insert into tb_row_2_col values (1,'col1');
insert into tb_row_2_col values (1,'col2');
insert into tb_row_2_col values (1,'col3');
insert into tb_row_2_col values (2,'col4');
insert into tb_row_2_col values (2,'col5');
commit;
SQL> select * from tb_row_2_col;
ID VAL
1 col1
1 col2
1 col3
2 col4
2 col5
SQL>
if i execute a query the output should be like this
ID VAL
1 col1,col2,col3
2 col4,col5
Thanks in advance
S. Sathish KumarMost repeated question in the forum..
SQL> select id,max(ltrim(sys_connect_by_path(val,','),',')) res
2 from (select id,val,
3 row_number() over(partition by id order by val) rn
4 from tb_row_2_col)
5 start with rn = 1
6 connect by prior rn = rn -1
7 and prior id = id
8 group by id;
ID RES
1 col1,col2,col3
2 col4,col5<br>
Message was edited by:
jeneesh
Check here for variations.. -
Query to convert Row to column
Hi all,
I need a query to convert row value into column delimited by ','
create table tb_row_2_col (id number,val varchar2(100));
insert into tb_row_2_col values (1,'col1');
insert into tb_row_2_col values (1,'col2');
insert into tb_row_2_col values (1,'col3');
insert into tb_row_2_col values (2,'col4');
insert into tb_row_2_col values (2,'col5');
commit;
SQL> select * from tb_row_2_col;
ID VAL
1 col1
1 col2
1 col3
2 col4
2 col5
SQL>
if i execute a query the output should be like this
ID VAL
1 col1,col2,col3
2 col4,col5
Thanks in advance
S. Sathish KumarOr look for aggregation techniques against the forum helping by the search feature (top-right of the current page).
Nicolas. -
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 -
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 -
How to convert rows into columns with decode function
Hi,
How to convert rows into columns with the help of decode function in oracle.
thanks and regards
P Prakashsay
col1 col2
1 10
2 20
3 30
then use
select col1,
sum(decode(col2,10,10)) "new1"
sum(decode(col2,20,20))"new2"
sum(decode(col2,30,30))"new3"
from table_name
group by col1;
we used sum u can use ny function if wont u have to give the column name i.e col2 name also
so i think u got it nw
regards -
How to find out How many rows and coloumn exists in the Excel sheet
hai gurus,
present iam uploading data from presentation server to application server. when i use gui_upload the data is coming non-readable format.
so i used alsm_excel_to_int fm for that . but the problem is user can give any type of excel so... i need to know how many rows and coloumn s existed in that Excel
so is there any possiblity to get those values(Total rows and total coloumns).
plz help me..
if any one answered , appreciate with reward points,
thanks®ards,
Venu.Tsee you have to come into an agreement with other system before starting development..
Please dont do unnecessary coding for impractical things ..you may solve this but this is not good way of working in eRP packages..
Al least u can get final list of all Columns and which can be blank or non blank like this
then u can do coding for this scenerio
regards...
Message was edited by:
Madan Gopal Sharma -
Can we give two combo box destination in same rows and coloumn?
Hi Experts,
Can you tell me Is it possible two combo destination in same rows and coloumn. If possible explain me..
i have tried first destination place in one particular cells and second placed it same place. while running it shows second one placed value only showing.
First combo box value is not showingHi Manikandan
What are you trying to achieve here? Offcourse, later will replace the previous. How do you need it to behave like? What is the ultimate goal?
Runali -
Convert rows into columns nad vice versa in 10g
how to convert rows into columns in 10g??
Qwerty wrote:
see below for rows to column case
SQL> WITH t as
2 (
3 SELECT 'US' test_string FROM DUAL UNION
4 SELECT 'AMERICA' FROM DUAL UNION
5 SELECT'HOLLYWOOD' FROM DUAL UNION
6 SELECT 'WASHINGTON' FROM DUAL
7 )
8 select ltrim (sys_connect_by_path(test_string,','),',') test_string
9 from (
10 SELECT row_number() over(order by test_string) rno, test_string
11 FROM t)
12 WHERE connect_by_isleaf = 1 and rownum=1
13 connect by rno = prior rno+1;
TEST_STRING
AMERICA,HOLLYWOOD,US,WASHINGTONI hope you can do it for column to rows now.That's not really rows to columns. That's rows to a column, which is more commonly called string aggregation.
Rows to columns (or pivot) is more like:
SQL> ed
Wrote file afiedt.buf
1 WITH t as
2 (
3 SELECT 'US' test_string FROM DUAL UNION
4 SELECT 'AMERICA' FROM DUAL UNION
5 SELECT'HOLLYWOOD' FROM DUAL UNION
6 SELECT 'WASHINGTON' FROM DUAL
7 )
8 --
9 select max(decode(rn,1,test_string)) as col_1
10 ,max(decode(rn,2,test_string)) as col_2
11 ,max(decode(rn,3,test_string)) as col_3
12 ,max(decode(rn,4,test_string)) as col_4
13* from (select test_string, row_number() over (order by test_string) as rn from t)
SQL> /
COL_1 COL_2 COL_3 COL_4
AMERICA HOLLYWOOD US WASHINGTON
SQL>And columns to rows (or unpivot) is like:
SQL> ed
Wrote file afiedt.buf
1 WITH t as
2 (
3 SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
4 )
5 --
6 select col_1 as col from t union all
7 select col_2 from t union all
8 select col_3 from t union all
9* select col_4 from t
SQL> /
COL
US
AMERICA
HOLLYWOOD
WASHINGTONor...
SQL> ed
Wrote file afiedt.buf
1 WITH t as
2 (
3 SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
4 )
5 --
6 select decode(rownum,1,col_1,2,col_2,3,col_3,4,col_4) as col
7* from t, (select * from dual connect by rownum <= 4)
SQL> /
COL
US
AMERICA
HOLLYWOOD
WASHINGTON
SQL> -
Converting rows to collums with out using pivot ?
Hi,
Is it possible to convert the rows to collums ,and collums to rows wit out using pivot table?
Tqhi,
Its not possible to convert rows to columns, columns to rows out of pivot.
In table view ther will be column and measure only.
Regards,
VG -
Converting rows to columns using t-sql
Hi All,
I have a table with 3 columns, let say ID1 , ID2, Flag
My Source data looks like this..
ID1 ID2 Flag
1 1 0
1 2 0
1 3 0
2 7 0
2 8 1
2 9 0
4 5 0
Now My output should look like this..
ID1 Newcol1 NewFlag1 Newcol2 NewFlag2 Newcol3 NewFlag3
1 1 0
2 0 3
0
2 7 0
8 1 9
0
4 5 0
null null null null
Basically I want to convert rows to columns and to get above output I need t-SQL query.
Thanks in advance
RH
sqlYou can do it by this query:
declare @table table ( ID1 int, ID2 int, Flag int)
insert @table values ( 1,1,0 ),( 1,2,0 ),( 1,3,0 ),( 2,7,0 ),( 2,8,1 ),( 2,9,0 ),( 4,5,0 )
WITH cte1
AS ( SELECT Id1 ,
ROW_NUMBER() over (partition by ID1 order by ID1 ) as Sequence ,
ID2 ,
Flag
FROM @table
cte2
AS ( SELECT Id1 ,
ColumnTitle + LTRIM(RTRIM(STR(Sequence))) AS ColumnTitle ,
ColumnData
FROM cte1 UNPIVOT ( ColumnData FOR ColumnTitle IN ( [ID2], [Flag] ) ) AS UP
SELECT Id1 ,
[ID21] FirstID2 ,
[Flag1] FirstFlag ,
[ID22] SecondID2 ,
[Flag2] SecondFlag ,
[ID23] ThirdID2 ,
[Flag3] ThirdFlag
FROM cte2 PIVOT ( MAX(ColumnData) FOR ColumnTitle IN ( [ID21],
[Flag1],
[ID22],
[Flag2],
[ID23],
[Flag3] ) ) PV
If you want to know more detail, please visit my old article about this method:
T-SQL: PIVOT Ordered pair Columns
T-SQL e-book by TechNet Wiki Community
My Blog
My Articles -
Select Statement - How do i convert rows to columns
Hi, i need your help please.
i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
no i can assign articles to this option.
Article 1, 2, 3, 4
in the table it looks like this
ARTICLE_ID T_OPTIONS
1 A
1 B
2 C
3 A
3 C
But now i want to have a select statement which convert rows to columns, it has to look like this
ARTICLE A B C
1 x x
2 x
3 x x
Can you help me!?
Edited by: Dila on 02.08.2012 01:52
Edited by: Dila on 02.08.2012 01:53Dila wrote:
Hi, i need your help please.
i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
no i can assign articles to this option.
Article 1, 2, 3, 4
in the table it looks like this
ARTICLE_ID T_OPTIONS
1 A
1 B
2 C
3 A
3 C
But now i want to have a select statement which convert rows to columns, it has to look like this
ARTICLE A B C
1 x x
2 x
3 x x
Can you help me!?
Edited by: Dila on 02.08.2012 01:52
Edited by: Dila on 02.08.2012 01:53Read {message:id=9360002} and {message:id=9360005}
SQL> ed
Wrote file afiedt.buf
1 with sample_data as
2 (
3 select 1 ARTICLE_ID,'A' T_OPTIONS from dual union all
4 select 1, 'B' from dual union all
5 select 2, 'C' from dual union all
6 select 3, 'A' from dual union all
7 select 3, 'C' from dual
8 )
9 select article_id,
10 decode(sum(case
11 when t_options = 'A' then 1
12 else 0
13 end), 0, null,
14 'X') A,
15 decode(sum(case
16 when t_options = 'B' then 1
17 else 0
18 end), 0, null,
19 'X') B,
20 decode(sum(case
21 when t_options = 'C' then 1
22 else 0
23 end), 0, null,
24 'X') C
25 from sample_data
26* group by article_id
SQL> /
ARTICLE_ID A B C
1 X X
2 X
3 X X -
How to convert rows to columns of a table?
I want to convert rows to columns of a table..
Query in SQL??965373 wrote:
I want to convert rows to columns of a table..
Query in SQL??PIVOT by Frank Help for a query to add columns
PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740 -
How to convert rows to columns in sql server 2008
How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)
Lookup the Pivot transformation. From BOL:
The Pivot transformation makes a normalized data set into a less normalized
but more compact version by pivoting the input data on a column value. For
example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
null values.
When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
The column is passed through unchanged to the output. Because many input rows
can result only in one output row, the transformation copies only the first
input value for the column.
The column acts as the key or part of the key that identifies a set of
records.
The column defines the pivot. The values in this column are associated with
columns in the pivoted dataset.
The column contains values that are placed in the columns that the pivot
creates.
Paul
Maybe you are looking for
-
Thomson gateway router and airplay
Hi all, I have recently purchased the B&W Zeppelin Air & while the sound is fantastic (for what it is...audiophile might disagree), I am having issues with it staying connected to the network. While playing a playlists using Airplay it will all of a
-
if you have iPhone4 and can you take out the sim card from iPhone4 and transfer it in to new iPhone4s?
-
VPN Settings iphone 3G: How to activate "hybrid mode"?
In the web configuration utility there is an option for "hybrid mode". How can I activate it manually, without using the enterprise deployment? There is no option for this in the CISCO ipsec tab.
-
i am having trouble burning my program to DVD. i have tried the build and format and burn functions but when i put the dvd in a external player it does not recognize the disk. my program plays fine in simulation and the disk works fine on my macbook,
-
Brand new U530 Touch laptop with Windows 8.1. Whenever I boot up and the MSN account login screen appears, the password line already has multiple lines of key entries. These entries were not generated by me and are not the password. If I backspace t