ROWS to COLUMNS and COLUMNS to ROWS (Earlier Docs/Threads Didn't help)
Hi Guys,
I have gone through the earlier threads and documents on this. But didn't help.
In lots of cases they have used DECODE statement. However, it works if you know the number of columns and rows...what if we are not sure of the number of records? How does it work?
Please direct me to any thread or any other documents.
-Sandeep
Pivoting in SQL
a. 10g Model Clause
SQL> create table test(id varchar2(2), des varchar2(4), t number);
Table created
SQL> INSERT INTO test values(’A',’a1',12);
1 row inserted
SQL> INSERT INTO test values(’A',’a2',3);
1 row inserted
SQL> INSERT INTO test values(’A',’a3',1);
1 row inserted
SQL> INSERT INTO test values(’B',’a1',10);
1 row inserted
SQL> INSERT INTO test values(’B',’a2',23);
1 row inserted
SQL> INSERT INTO test values(’C',’a3',45);
1 row inserted
SQL> commit;
Commit complete
SQL> SELECT * FROM test;
ID DES T
A a1 12
A a2 3
A a3 1
B a1 10
B a2 23
C a3 45
6 rows selected
SQL> select distinct i, A1, A2, A3
2 from test c
3 model
4 ignore nav
5 dimension by(c.id i,c.des d)
6 measures(c.t t, 0 A1, 0 A2, 0 A3)
7 rules(
8 A1[any,any] = t[cv(i),d = ‘a1'],
9 A2[any,any] = t[cv(i),d = ‘a2'],
10 A3[any,any] = t[cv(i),d = ‘a3']
11 );
I A1 A2 A3
C 0 0 45
B 10 23 0
A 12 3 1
SQL> select distinct d, A, B, C
2 from test c
3 model
4 ignore nav
5 dimension by(c.id i,c.des d)
6 measures(c.t t, 0 A, 0 B, 0 C)
7 rules(
8 A[any,any] = t[i = ‘A’, cv(d)],
9 B[any,any] = t[i = ‘B’, cv(d)],
10 C[any,any] = t[i = ‘C’, cv(d)]
11 );
D A B C
a1 12 10 0
a3 1 0 45
a2 3 23 0
b. Pivoting INSERT example;
INSERT ALL
INTO sales_info VALUES (employee_id,week_id,sales_MON)
INTO sales_info VALUES (employee_id,week_id,sales_TUE)
INTO sales_info VALUES (employee_id,week_id,sales_WED)
INTO sales_info VALUES (employee_id,week_id,sales_THUR)
INTO sales_info VALUES (employee_id,week_id, sales_FRI)
SELECT EMPLOYEE_ID, week_id, sales_MON, sales_TUE,sales_WED, sales_THUR,sales_FRI
FROM sales_source_data;
c. 11g sql pivot keyword
http://oraclebizint.wordpress.com/2007/09/05/oracle-11g-pivot-and-unpivot/
d. reference for others :)
http://laurentschneider.blogspot.com/2005/08/pivot-table.html
Similar Messages
-
I'm trying to open a 900kb Word doc (240pages) in Pages but get this error message: Import Warning - A table was too big. Only the first 40 columns and 1,000 rows were imported.
Julian,
Pages simply won't support a table with that many rows. If you need that many, you must use another application.
Perhaps the originator could use a tabbed list rather than a table. That's the only way you will be able to contain a list that long in Pages. You can do the conversion yourself if you open the Word document in LibreOffice, Copy the Table, Paste the Table into Numbers, Export the Numbers doc to CSV, and import to Pages. In Pages Find and Replace the Commas with Tabs.
There are probably other ways, but that's what comes to mind here.
Jerry -
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 -
Can anybody help....SQL to display row as column and column as rows
Can anybody help in writing a SQL to display row as column and column as rows?
Thankscheck this link:
Re: Creating Views - from rows to a new column? -
Rows as Columns and Columns as Rows
Hi,
How to print rows as columns and columns as rows?
Suppose I've the following data
colA colB
X 1
Y 2
Z 3
I want the output to be something like
X Y Z
1 2 3.
Is this possible? Please let me know.
Regards,
Jai.The following assumes that there is only one value of colb for each value of cola, but allows for any number of values of cola. The script below creates the query and results below that, given the test data that you provided.
-- script:
STORE SET saved_settings REPLACE
SET ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF WRAP ON
SPOOL query.sql
SELECT 'SELECT MAX (DECODE (cola, ''' || cola || ''', colb)) AS "' || cola || '"'
FROM (SELECT MIN (cola) AS cola
FROM test_table)
SELECT ', MAX (DECODE (cola, ''' || cola || ''', colb)) AS "' || cola || '"'
FROM (SELECT DISTINCT cola
FROM test_table
WHERE cola >
(SELECT MIN (cola)
FROM test_table))
PROMPT FROM test_table
PROMPT /
SPOOL OFF
START saved_settings
START query.sql
-- query and results:
SQL> SELECT MAX (DECODE (cola, 'X', colb)) AS "X"
2 , MAX (DECODE (cola, 'Y', colb)) AS "Y"
3 , MAX (DECODE (cola, 'Z', colb)) AS "Z"
4 FROM test_table
5 /
X Y Z
1 2 3
SQL> -
Display only one row for distinct columns and with multiple rows their valu
Hi,
I have a table having some similar rows for some columns and multiple different rows for some other columns
i.e
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
9825000111 01-jan-06 'a' 991543154 02-feb-06 d
9825000111 01-jan-06 'a' 154845545 10-mar-06 a
What i want is to display only one row for above distinct row along with multiple non distinct colums
ie
o_mobile_no o_doc_date o_status d_mobile_no d_doc_date d_status
9825000111 01-jan-06 'a' 980515464 01-feb-06 c
991543154 02-feb-06 d
154845545 10-mar-06 a
regards,
KumarRe: SQL Help
-
Interchanging of Rows to Columns and Columns to Rows
Can anyone help me in this query ....
Interchanging of Rows to Columns and Columns to Rows in Oracle
Ex :- Actual Data
EmpId Ename Sal
1 A 2000
2 B 3000
3 C 1000
4 D 3000
Query Result should be like below ::::::::::
after Transposing [ Interchanging of Rows to Columns and Columns to Rows ]the data should come like below
Empid 1 2 3 4
EName A B C D
Sal 2000 3000 1000 3000
Thanks
Kavitha and SudhirPlease see the following links
transpose my table column
http://asktom.oracle.com/pls/ask/f?p=4950:8:1532380262922962983::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:52733433785851
pivot a result set
http://asktom.oracle.com/pls/ask/f?p=4950:8:1532380262922962983::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:124812348063 -
Webdynpro IWDTable - Item table , grouped column and Column difference?
I had added Column to Table in webdynpro java UI
but , when I am getting the values for the same from BAPI was displayed but , when I am saving , it is not saving
Is there any difference between GroupedColumn and Column?
The other columns which were there in the table are all Grouped Column for the ItemTable.
Also, when I deployed the code in the j2ee server, when I open my UWL , the columns are displayed in the bottom .. whether it is coming because I have not groupedcolumn?
Thanks in advance...
KiranI had added Column to Table in webdynpro java UI
but , when I am getting the values for the same from BAPI was displayed but , when I am saving , it is not saving
Is there any difference between GroupedColumn and Column?
The other columns which were there in the table are all Grouped Column for the ItemTable.
Also, when I deployed the code in the j2ee server, when I open my UWL , the columns are displayed in the bottom .. whether it is coming because I have not groupedcolumn?
Thanks in advance...
Kiran -
Can a style control Columns and Column breaks?
Good day,
I am trying something very new and different for me in indesign.
I am creating a catalog, that the text is being input by importing XML. I have created styles for each of the tags coming in from the XML.
but I am currious, Can I tell a style that I would like create a Column. and have my first tag put into the column, then at the next part of the text I have a column break at the start of the text to move it to the next column?
I am just trying to learn how to automate as much of this as possible.
Thank you so much for the help!
Dave StableyAnd while you can create an object style that will define the number of columns in a frame (and you can set a fixed width), I'm not sure you can get ID to create new frames when placing XML, but it may be possible (it certainly is with ordinary text files). You have to try, maybe experimenting with Smart Text Reflow.
-
ALV report with dynamic columns, and repeated structure rows
Hey Guys,
I've done some ALV programming, but most of the reports were straight forward. This one is a little interesting. So here go the questions...
Q1: Regarding Columns:
What is the best way to code a report with columns being dynamic. This is one of the parameters the user is going to enter in his input.
Q2: Regarding Rows:
I want to repeat a structure(say it contains f1, f2, f3) multiple time in rows. What is the best way to do it? The labels for these fields have to appear in the first column.
Below is the visual representation of the questions.
Jan 06 , Feb 06, Mar 06....(dynamic)
material 1
Current Stock
current required
$Value of stock
material 2
Current Stock
current required
$Value of stock
material 3
Current Stock
current required
$Value of stock
Thanks for your help.
Sumit.Hi Sumit,
Just check this sample from one of the SAP site
ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
Applies To:
ABAP / ALV Grid
Article Summary
ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
Code Sample
REPORT zcdf_dynamic_table.
* Dynamic ALV Grid with Cell Coloring.
* Build a field catalog dynamically and provide the ability to color
* the cells.
* To test, copy this code to any program name and create screen 100
* as described in the comments. After the screen is displayed, hit
* enter to exit the screen.
* Tested in 4.6C and 6.20
* Charles Folwell - [email protected] - Feb 2, 2005
DATA:
r_dyn_table TYPE REF TO data,
r_wa_dyn_table TYPE REF TO data,
r_dock_ctnr TYPE REF TO cl_gui_docking_container,
r_alv_grid TYPE REF TO cl_gui_alv_grid,
t_fieldcat1 TYPE lvc_t_fcat, "with cell color
t_fieldcat2 TYPE lvc_t_fcat, "without cell color
wa_fieldcat LIKE LINE OF t_fieldcat1,
wa_cellcolors TYPE LINE OF lvc_t_scol,
wa_is_layout TYPE lvc_s_layo.
FIELD-SYMBOLS:
<t_dyn_table> TYPE STANDARD TABLE,
<wa_dyn_table> TYPE ANY,
<t_cellcolors> TYPE lvc_t_scol,
<w_field> TYPE ANY.
START-OF-SELECTION.
* Build field catalog based on your criteria.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-coltext = 'My Field 1'.
wa_fieldcat-seltext = wa_fieldcat-coltext.
APPEND wa_fieldcat TO t_fieldcat1.
wa_fieldcat-fieldname = 'FIELD2'.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-coltext = 'My Field 2'.
wa_fieldcat-seltext = wa_fieldcat-coltext.
APPEND wa_fieldcat TO t_fieldcat1.
* Before adding cell color table, save fieldcatalog to pass
* to ALV call. The ALV call needs a fieldcatalog without
* the internal table for cell coloring.
t_fieldcat2[] = t_fieldcat1[].
* Add cell color table.
* CALENDAR_TYPE is a structure in the dictionary with a
* field called COLTAB of type LVC_T_SCOL. You can use
* any structure and field that has the type LVC_T_SCOL.
wa_fieldcat-fieldname = 'T_CELLCOLORS'.
wa_fieldcat-ref_field = 'COLTAB'.
wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
APPEND wa_fieldcat TO t_fieldcat1.
* Create dynamic table including the internal table
* for cell coloring.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat1
IMPORTING
ep_table = r_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Get access to new table using field symbol.
ASSIGN r_dyn_table->* TO <t_dyn_table>.
* Create work area for new table.
CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
* Get access to new work area using field symbol.
ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
* Get data into table from somewhere. Field names are
* known at this point because field catalog is already
* built. Read field names from the field catalog or use
* COMPONENT <number> in a DO loop to access the fields. A
* simpler hard coded approach is used here.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'ABC'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'XYZ'.
APPEND <wa_dyn_table> TO <t_dyn_table>.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'TUV'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
<w_field> = 'DEF'.
APPEND <wa_dyn_table> TO <t_dyn_table>.
* Color cells based on your criteria. In this example, a test on
* FIELD2 is used to decide on color.
LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
* Get access to internal table used to color cells.
ASSIGN COMPONENT 'T_CELLCOLORS'
OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
CLEAR wa_cellcolors.
wa_cellcolors-fname = 'FIELD2'.
IF <w_field> = 'DEF'.
wa_cellcolors-color-col = '7'.
ELSE.
wa_cellcolors-color-col = '5'.
ENDIF.
APPEND wa_cellcolors TO <t_cellcolors>.
MODIFY <t_dyn_table> FROM <wa_dyn_table>.
ENDLOOP.
* Display screen. Define screen 100 as empty, with next screen
* set to 0 and flow logic of:
* PROCESS BEFORE OUTPUT.
* MODULE initialization.
* PROCESS AFTER INPUT.
CALL SCREEN 100.
* MODULE initialization OUTPUT
MODULE initialization OUTPUT.
* Set up for ALV display.
IF r_dock_ctnr IS INITIAL.
CREATE OBJECT r_dock_ctnr
EXPORTING
side = cl_gui_docking_container=>dock_at_left
ratio = '90'.
CREATE OBJECT r_alv_grid
EXPORTING i_parent = r_dock_ctnr.
* Set ALV controls for cell coloring table.
wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
* Display.
CALL METHOD r_alv_grid->set_table_for_first_display
EXPORTING
is_layout = wa_is_layout
CHANGING
it_outtab = <t_dyn_table>
it_fieldcatalog = t_fieldcat2.
ELSE. "grid already prepared
* Refresh display.
CALL METHOD r_alv_grid->refresh_table_display
EXPORTING
i_soft_refresh = ' '
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDMODULE. " initialization OUTPUT
Regards
vijay -
Including both the Jquery script to calculate the total of calculated column and freeze header row
Hi
I managed to get this code from here,
http://techtrainingnotes.blogspot.in/2013/03/freezing-title-row-of-sharepoint-2010.html done on the page
I also managed to get this code from here, http://www.sharepointed.com/2012/11/28/jquery-total-calculated-column-in-sharpoint-2010/ done on another page.
However, I need this to be done on the same page. When I do this, I only get the freeze header thingy to be up and not the calculated column. Could something be blocking.Hi,
You take the code below for a try in your environment after modified it a bit to suit the structure of your page:
<script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
// update the list after the page has loaded
_spBodyOnLoadFunctionNames.push("TTNListScroll");
function TTNListScroll()
// Scrolling list code from TechTrainingNotes.blogspot.com
// Edit the next line with your list's summary name
var SummaryName = "List28_frozenheader ";
var TTNmyTable;
var TTNListDiv = document.createElement('div');
var TTNHeadingDiv = document.createElement('div');
var tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++)
if(tables[i].summary == SummaryName)
TTNmyTable = tables[i];
break;
if(TTNmyTable == undefined)
// // Table not found!
// you may want to comment out the next line after testing
alert("table '" + SummaryName + "' not found");
return;
// make a copy of the table for the heading area
TTNHeadingDiv.appendChild(TTNmyTable.cloneNode(true));
TTNHeadingDiv.id="TTNheading";
TTNListDiv.appendChild(TTNmyTable.cloneNode(true));
TTNListDiv.id="TTNlist";
TTNListDiv.width="100%";
// udpate the page
var TTNnode = TTNmyTable.parentNode;
TTNnode.replaceChild(TTNHeadingDiv, TTNmyTable);
TTNnode.appendChild(TTNListDiv);
// hide the heading row of the main list
TTNListDiv.childNodes[0].rows[0].style.visibility='hidden';
// make the DIV for the heading the same width as the main list
TTNHeadingDiv.childNodes[0].style.width = TTNListDiv.childNodes[0].offsetWidth;
getSum(3);
//pass the column number to this function
function getSum(col)
var m = "$"; //change to "" for non-money format
var arrayList = $("table.ms-listviewtable:first> tbody> tr:gt(0)").find(">td:eq("+col+")");
var x = 0;
var p1 = "";
var p2 = "";
$.each(arrayList, function(){
//console.log('$(this).text(): '+$(this).text());
x += Number($(this).text().replace(/\$|,|\)/g, "").replace(/\(/g,"-"));
//console.log('x: '+x);
//format for negative numbers
if (x < 0)
p1 = "(";
p2 = ")";
x = Math.abs(x);
$('#diidSortcal').attr('visibility','visible');
$('#diidSortcal').text($('#diidSortcal').text()+'(sum: '+x+')');
function addCommas(nStr)
//formats number
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1))
x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
</script>
<style type="text/css">
#TTNheading
height:28px;
#TTNlist
height:200px;
overflow-y:scroll !important;
overflow-x:auto
</style>
Then you might get something like this:
Feel free to reply if there are still any questions.
Best regards
Patrick Liang
TechNet Community Support -
How to transpose rows to columns and columns to rows in alv grid
can u plz tell me in alv grid how to
display data from itab having data
1
2
3 and so on
how to print in alv in a single row ie
1 2 3 and so onchk this code...
REPORT Z_TRANSPOSEALV .
* Type pools declaration for ALV
TYPE-POOLS: slis.
*Declarations for ALV, dynamic table and col no for transpose
DATA: l_col TYPE sy-tabix,
l_structure TYPE REF TO data,
l_dyntable TYPE REF TO data,
wa_lvc_cat TYPE lvc_s_fcat,
lt_lvc_cat TYPE lvc_t_fcat,
lt_fieldcatalogue TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_layout TYPE slis_layout_alv.
*Field symbols declarations
FIELD-SYMBOLS :
<header> TYPE ANY,
<dynheader> TYPE ANY,
<dyndata> TYPE ANY,
<ls_table> TYPE ANY,
<dynamictable> TYPE STANDARD TABLE,
<it_table> TYPE STANDARD TABLE.
*Input the name of the table
PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY.
*Initialization event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
* Create internal table of dynamic type
CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN l_dyntable->* TO <it_table>.
*select statement to select data from the table as input into
*our dynamic internal table.
*Here i have restricted only till 5 rows.
*You can set a variable and give no of rows to be fetched
*The variable can be set in your select statement
SELECT * INTO CORRESPONDING FIELDS OF TABLE <it_table>
FROM (p_table) up to 5 rows.
*Fieldcatalogue definitions
wa_lvc_cat-fieldname = 'COLUMNTEXT'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.
wa_fieldcat-fieldname = 'COLUMNTEXT'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
wa_fieldcat-key = 'X'..
APPEND wa_fieldcat TO lt_fieldcat.
DESCRIBE TABLE <it_table>.
DO sy-tfill TIMES.
* For each line, a column 'VALUEx' is created in the fieldcatalog
* Build Fieldcatalog
WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.
CONCATENATE 'VALUE' wa_lvc_cat-fieldname
INTO wa_lvc_cat-fieldname.
wa_lvc_cat-ref_field = 'VALUE'.
wa_lvc_cat-ref_table = 'LVC_S_DETA'.
APPEND wa_lvc_cat TO lt_lvc_cat.
* Build Fieldcatalog
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = wa_lvc_cat-fieldname.
wa_fieldcat-ref_fieldname = 'VALUE'.
wa_fieldcat-ref_tabname = 'LVC_S_DETA'.
APPEND wa_fieldcat TO lt_fieldcat.
ENDDO.
* Create dynamic internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_lvc_cat
IMPORTING
ep_table = l_dyntable. ASSIGN l_dyntable->* TO <dynamictable>.
* Create structure as structure of the internal table
CREATE DATA l_structure LIKE LINE OF <dynamictable>.
ASSIGN l_structure->* TO <header>.
* Create structure = structure of the internal table
CREATE DATA l_structure LIKE LINE OF <it_table>.
ASSIGN l_structure->* TO <ls_table>.
* Create field catalog from our table structure
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
CHANGING
ct_fieldcat = lt_fieldcatalogue
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. DESCRIBE TABLE lt_fieldcatalogue.
* Fill the internal to display <dynamictable>
DO sy-tfill TIMES.
IF sy-index = 1.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.
ENDIF.
* For each field of it_table
ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <dynheader>.
IF sy-subrc NE 0. EXIT .ENDIF.
READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.
* Fill 1st column
<dynheader> = wa_fieldcat-seltext_m.
IF <dynheader> IS INITIAL.
<dynheader> = wa_fieldcat-fieldname.
ENDIF.
*Filling the other columns
LOOP AT <it_table> INTO <ls_table>.
l_col = sy-tabix + 1.
ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO <dyndata>.
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT l_col OF STRUCTURE <header> TO
<dynheader>.
IF sy-subrc NE 0. EXIT .ENDIF.
WRITE <dyndata> TO <dynheader> LEFT-JUSTIFIED.
ENDLOOP.
APPEND <header> TO <dynamictable>.
ENDDO.
*Layout for ALV output
lt_layout-zebra = 'X'.
lt_layout-no_colhead = 'X'..
lt_layout-colwidth_optimize ='X'.
lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'.
*ALV Grid output for display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = lt_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = <dynamictable>. -
Displaying rows as columns and coumns as rows?
Can we do this?
Thanks.Can we do this?Yes.
Google it and you will find HOW to do it. -
Retrieve 3 rows of data and put each row in different position on screen
I need to retrieve 3 consecutive rows of data (easy) and need to put each row's data in an entirely different location on the home page
for example,
row 1 needs to go up in the top left content box
row 2 needs to go in the large content area in the middle of the page
row 3 needs to be put down in the footer of the page
what's the most efficient way to do this ?Ok, I've tried to research this a bit more, but I'm no further forward
So if I have a query...
<cfquery name="getData" datasource="foo">
SELECT *
FROM 00_pricelist
</cfquery>
<cfoutput query="GetData" startrow=1 maxrows=3 >
<!--- surrounding table 1 --->
#getData.uneak_code[1]#<br />
<!--- surrounding table 2 --->
#getData.uneak_code[2]#<br />
<!--- surrounding table 3 --->
#getData.uneak_code[3]#<br />
</cfoutput>
can you tell me what I'm doing wrong ? -
Transposing column 1 data as columns and column 2 data as records
Hi Sirs,
I have a table having data in the form
Present data format
Interview_no Question Answer
1 Q1 A1.1
1 Q2 A1.2
1 Q3 A1.3
1 Q4 A1.4
1 Q5 A1.5
1 Q6 A1.6
1 Q7 A1.7
2 Q1 A2.1
2 Q2 A2.2
2 Q3 A2.3
2 Q4 A2.4
2 Q5 A2.5
2 Q6 A2.6
2 Q7 A2.7
3 Q1 A3.1
3 Q2 A3.2
3 Q3 A3.3
3 Q4 A3.4
3 Q5 A3.5
3 Q6 A3.6
3 Q7 A3.7
4 Q1 A4.1
4 Q2 A4.2
4 Q3 A4.3
4 Q4 A4.4
4 Q5 A4.5
4 Q6 A4.6
4 Q7 A4.7
what I need is to change it into
Required format
Interview_no Q1 Q2 Q3 Q4 Q5 Q6 Q7
1 A1.1 A1.2 A1.3 A1.4 A1.5 A1.6 A1.7
2 A2.1 A2.2 A2.3 A2.4 A2.5 A2.6 A2.7
3 A3.1 A3.2 A3.3 A3.4 A3.5 A3.6 A3.7
4 A4.1 A4.2 A4.3 A4.4 A4.5 A4.6 A4.7
I am sorry to use that much of space but I think this was the best way to ask the problem. Can we do this using SQL only or we need to go for Pl/Sql I have tried writing a procedure but can't get what eactly I want. I also serched on the net there are a few articles on transposing but they didn't help a lot.
Please help me with the code.
Thanks & RegardsSQL> ed
Wrote file afiedt.buf
1 with t as (select 1 as interview_no, 'Q1' as question, 'A1.1' as answer from dual union all
2 select 1, 'Q2', 'A1.2' from dual union all
3 select 1, 'Q3', 'A1.3' from dual union all
4 select 1, 'Q4', 'A1.4' from dual union all
5 select 1, 'Q5', 'A1.5' from dual union all
6 select 1, 'Q6', 'A1.6' from dual union all
7 select 1, 'Q7', 'A1.7' from dual union all
8 select 2, 'Q1', 'A2.1' from dual union all
9 select 2, 'Q2', 'A2.2' from dual union all
10 select 2, 'Q3', 'A2.3' from dual union all
11 select 2, 'Q4', 'A2.4' from dual union all
12 select 2, 'Q5', 'A2.5' from dual union all
13 select 2, 'Q6', 'A2.6' from dual union all
14 select 2, 'Q7', 'A2.7' from dual union all
15 select 3, 'Q1', 'A3.1' from dual union all
16 select 3, 'Q2', 'A3.2' from dual union all
17 select 3, 'Q3', 'A3.3' from dual union all
18 select 3, 'Q4', 'A3.4' from dual union all
19 select 3, 'Q5', 'A3.5' from dual union all
20 select 3, 'Q6', 'A3.6' from dual union all
21 select 3, 'Q7', 'A3.7' from dual union all
22 select 4, 'Q1', 'A4.1' from dual union all
23 select 4, 'Q2', 'A4.2' from dual union all
24 select 4, 'Q3', 'A4.3' from dual union all
25 select 4, 'Q4', 'A4.4' from dual union all
26 select 4, 'Q5', 'A4.5' from dual union all
27 select 4, 'Q6', 'A4.6' from dual union all
28 select 4, 'Q7', 'A4.7' from dual)
29 -- END OF TEST DATA
30 select interview_no
31 ,max(decode(question,'Q1',answer)) as Q1
32 ,max(decode(question,'Q2',answer)) as Q2
33 ,max(decode(question,'Q3',answer)) as Q3
34 ,max(decode(question,'Q4',answer)) as Q4
35 ,max(decode(question,'Q5',answer)) as Q5
36 ,max(decode(question,'Q6',answer)) as Q6
37 ,max(decode(question,'Q7',answer)) as Q7
38 from t
39 group by interview_no
40* order by interview_no
SQL> /
INTERVIEW_NO Q1 Q2 Q3 Q4 Q5 Q6 Q7
1 A1.1 A1.2 A1.3 A1.4 A1.5 A1.6 A1.7
2 A2.1 A2.2 A2.3 A2.4 A2.5 A2.6 A2.7
3 A3.1 A3.2 A3.3 A3.4 A3.5 A3.6 A3.7
4 A4.1 A4.2 A4.3 A4.4 A4.5 A4.6 A4.7
SQL>
Maybe you are looking for
-
Problem with Xfce-svn & thunar
Hi, I've got a problem with Xfce-svn installed via pacman from Server = http://arch.os-zen.net/pkg/xfce-svn After logging, Xfce is loading and after while I can see 2 panels and black screen (and without icons on desktop) although I set the wallpaper
-
XML over HTTP using BPEL (not using SOAP)... is this possible?
Hi there. We're trying to expose a BPEL process which will be exclusively triggered from a HTTP POST. The Client Partner Link in the BPEL process models Oracle's Transparent PunchOut standard. This standard is strict XML-over-HTTP, SOAP is not involv
-
Sql query ..need idea to write complex query
Hi there, I have assigned the task to write a sql query to get the output as the below stored proc does. In the proc conditions are given with IF statements. I really dont know how to give all the conditions for the period in a single sql query as I'
-
Why am i getting a BSOD when using after effects "CC Wide Time"
If I preview my footage whilst using the "cc wide time" effect, my PC Crashes to a blue screen of death. I'm using CS6 Creative cloud, any suggestions? Problem signature: Problem Event Name: BlueScreen OS Version: 6.1.7601.2.1.0.256.48 L
-
CJI3 for project definition Z001 is blank, but I go to CJ20N, for the activity, in edit/cost/actual, it shows the actual cost 40000 for cost element 5000001 in CJ88, it says: No settlement for this sender Message no. KD233 why can't settle?