How to convert the row in to a column.
Hi All,
i am having a query like this.
select
COUNT(PA_COL1),
COUNT(PA_COL2)
from ref_item;
here PA_COL1,PA_COL2 are column of table ref_item.
the out of this query is some thing like this
PA_COL1 PA_COL2
20000 12376
i want the output to be like
column record_count
PA_COL1 200000
PA_COL2 12376
Please help me to get the query for this.
also you have 30 columns in the table ref_item from PA_COL1 ....... PA_COL30.
Just cutting it out, I mistakenly pasted the wrong example here...thanks for pointing it out...
I am pasting a pretty good example from that thread itself, obviously you need to modify it to fit your need and thats the only way to learn:
WITH t AS
--( SELECT 'A' col FROM dual--
UNION ALL
SELECT 'B' FROM dual
UNION ALL
SELECT 'C' FROM dual
UNION ALL
SELECT 'D' FROM dual
SELECT REPLACE(MAX(SYS_CONNECT_BY_PATH(col,' ')),' ') "Col"
FROM
--(SELECT col,--
row_number() over (Order By col) AS curr,
row_number() over (Order By col) -1 AS prev
FROM t
CONNECT BY prev = Prior curr
START WITH curr = 1;
Edited by: Ankit Rathi on May 15, 2012 1:26 AM
Similar Messages
-
How to convert (multiple) rows output to multiple (columns)
Hii
I have wierd query. But not sure of how to get result out of it!!!
My query returns two rows for a query that i have posed.
Current Result
10
20
Expected Result
10 20
My problem here is i wanted the above two values to be stored in two variables in a single select statement.
If i use a cursor my problem will be solved.But i am not much intrested to use a cursor for a simple select statement.
is there any possibilty that i can convert the output of two rows to two columns??
I am using Oracle Release 10.1.0.2.0
Operating system Windows Xp.
People here will not appreciate the tags "Urgent". I know that :-(.
But some how i am forced to use this tag "urgent". Sorry for that.
If no answers i will in other way have to go to cursor :-(
Any help will be appreciated.
Thanks,
PavanAnother solution with model and you don't need a subquery
SELECT DEPT ,SUBSTR(LOCATION1,2) LOCATION1, SUBSTR(LOCATION2,2) LOCATION2,SUBSTR(LOCATION3,2) LOCATION3
FROM T
MODEL
RETURN UPDATED ROWS
PARTITION BY ( DEPT )
DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY DEPT ORDER BY LOCATION ) AS POSITION )
MEASURES ( location,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION1 ,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION2,
CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION3 )IGNORE NAV
RULES
UPSERT
ITERATE( 1000)
UNTIL ( PRESENTV(LOCATION[ITERATION_NUMBER+2],1,0) = 0)
( LOCATION1[0] =LOCATION1[0] || CASE WHEN ITERATION_NUMBER+1=1 THEN ',' || LOCATION1[ ITERATION_NUMBER+1] END,
LOCATION2[0] =LOCATION2[0] || CASE WHEN ITERATION_NUMBER+1=2 THEN ',' || LOCATION2[ ITERATION_NUMBER+1] END,
LOCATION3[0] =LOCATION3[0] || CASE WHEN ITERATION_NUMBER+1=3 THEN ',' || LOCATION3[ ITERATION_NUMBER+1] END )
ORDER BY DEPT
Demo
SQL> WITH T AS ( SELECT 'AB' DEPT,'MEB' LOCATION FROM DUAL UNION ALL
2 SELECT 'AB','MEB1' FROM DUAL UNION ALL
3 SELECT 'AB','MEB2' FROM DUAL UNION ALL
4 SELECT 'BC','MEB' FROM DUAL UNION ALL
5 SELECT 'BC','MEB' FROM DUAL UNION ALL
6 SELECT 'CD','MEN' FROM DUAL UNION ALL
7 SELECT 'CD','MEN' FROM DUAL
8 )
9 SELECT DEPT ,SUBSTR(LOCATION1,2) LOCATION1, SUBSTR(LOCATION2,2) LOCATION2,SUBSTR(LOCATION3,2)
LOCATION3
10 FROM T
11 MODEL
12 RETURN UPDATED ROWS
13 PARTITION BY ( DEPT )
14 DIMENSION BY ( ROW_NUMBER() OVER (PARTITION BY DEPT ORDER BY LOCATION ) AS POSITION )
15 MEASURES ( location,CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION1 ,CAST ( LOCATION AS
VARCHAR2(15)) AS LOCATION2,
16 CAST ( LOCATION AS VARCHAR2(15)) AS LOCATION3 )IGNORE NAV
17 RULES
18 UPSERT
19 ITERATE( 1000)
20 UNTIL ( PRESENTV(LOCATION[ITERATION_NUMBER+2],1,0) = 0)
21 ( LOCATION1[0] =LOCATION1[0] || CASE WHEN ITERATION_NUMBER+1=1 THEN ',' || LOCATION1[ I
TERATION_NUMBER+1] END,
22 LOCATION2[0] =LOCATION2[0] || CASE WHEN ITERATION_NUMBER+1=2 THEN ',' || LOCATION2[ ITER
ATION_NUMBER+1] END,
23 LOCATION3[0] =LOCATION3[0] || CASE WHEN ITERATION_NUMBER+1=3 THEN ',' || LOCATION3[ ITER
ATION_NUMBER+1] END )
24 ORDER BY DEPT
25 /
DE LOCATION1 LOCATION2 LOCATION3
AB MEB MEB1 MEB2
BC MEB MEB
CD MEN MEN
SQL>
SQL> -
How to convert a row into a column with the row headers displayed as column in javaFx?
How do in convert a row of data into column of data to display as shown below:
Column1|Column2|Column3|Column4
C1 | C2 | C3 | C4
C5 | C6 | C7 | C8
How to convert the above default behavior to as below
Column1| C1 | C5
Column2| C2 | C6
Column3| C3 | C7
Column4| C4 | C8.
-
To convert the row of an internal table into columns
Hi ,
I want to use the rows of a single column internal table itab1
to form another internal table itab2 with column names same as the rows of itab1 .
How is this possible?
Regards,
Harshit RungtaHi,
Check the link..[Convert Rows of internal table to Columns|http://docs.google.com/Doc?id=dfv2hmgs_5d6bcxqgp&hl=en] -
How to obtain the row data in the component datatable?
if I want to edit a row data, and then know which row is edited in the component datatable, and how to do?
How to obtain the row data in the component datatable, and update it to database, not simplely edit a simple table
Any ideas? ThanksThank you very much for your help Alexander !
It's quite confusing when you leave Struts and try to adapt your projects for JSF for the first time...
I wanted to click on a row with a "onMouseClick" on the TR tag like I used to do in Struts/JSTL. But it seems to be impossible in a dataTable.
Ok then. I've added a column at the end of the row with an icon.
But eventually I didn't need to declare link parameters.
In my BackingBean I did like this :
public String selectEventForUpdate() throws IllegalAccessException, InvocationTargetException {
PortletAgenda event = (PortletAgenda) JSFUtils.getInRequestMap("event");
BeanUtils.copyProperties(this, event);
return null;
}JSFUtils.getInRequestMap(...) is a method I wrote in a util object :
public static Object getInRequestMap(String name) {
Object res = null;
Map requestMap=FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if (requestMap!=null) {
res=requestMap.get(name);
return res;
} " event " is the name of the item in my dataTable list.
My backingBean has the same attributes as "event".
So when the page is reloaded I have a backingBean full with the selected properties to edit/update.
Thanks to your reply I realized that putting this form in the middle of the dataTable seems to be impossible.
So I put this form in a floating DIV in front of the table with a shadow.
It works :o) !
But I'm a little bit disapointed to be honest...
I used to build my web applications with Struts and JSTL and doing this kind of interface was really easy.
I've decided 3 days ago to convert into JSF because the "GUI Layer" seemed to be improved.
But now I realize that I cannot put a onMouseOver and onMouseClick on a row and I cannot display a different row in the middle of a table....
I think it's a shame because there is a facet for header and footer.
And it would be great if we could create our own personal facet that appears only if a condition is true.
For exemple " if the current item id is the same as the request parameter id then display the following facet content ....... (with a panel group and a form inside to update the row) "
It's easy to do that with JSTL thanks to c:forEach and c:if but it seems to be impossible to use JSTL tags like this during the dataTable iteration.
And JSF tags seems to have no logical tags like " if " or loops that can be nested in dataTable.
I really need to realize this interface (you click on a row then an edit form appears where you clicked).
Do I have to write a component myself that extends dataTable?
Do you know if writing such a component is hard to do for a beginner like me?
(I've juste discovered JSF 3 days ago and I've used Struts/JSTL for 2 years til now)
I'd be glad to have much advices from you about that.
Regards -
How to convert the javasource file(*.class) to execute file(*.exe)?
thank you!Although i have seen a few programs (that are platform specific) that will embed a small jvm into an exe with your class file, it is generally excepted that you cannot create an executable file using java. The JAR executable file is probably the closest your going to get
Pete -
I have a MacBook Pro, I want to copy Itunes files to an SD card to play in my car, the SD Card doesn't appear in Itunes when I insert it, and I don't know how to convert the files to the correct format, can anyone help?
Thank youSo it seems from reading the COMMAND manual that my first issue is that I used a 16GB SD card, and the manual says it will only recogize up to a 2GB SD card. I did use my MB Air's SD card slot and crated a folder and dragged the music files to it, then to the card. So I am going to get a 2GB card and try that next. Otherwise just stick with the iPOD connected. At least that is 8GB
-
How to increase the row height of the table in the smartform
Hi,
Can any one say,
How to increase the row height of the table in the smartform.
It is presently show the row width very small, i want to increase the row with of the table in the smartform.
Plase say how can we increase the row height in the smartform.Hi Ravi,
In Smartforms , Select the Table and you can adjust the cell hieghts in OUTPUT OPTIONs TAB.
Reward points if that Helps.
Manish -
How to Fix the row in sap script, its urgent......
Hi Experts,
first i explain my sap script, i have print void check in my script client give readymade format means box are there, lines are there. i have to fix in box and line data form database table. everthing is working fine. i got all data. i have total 6 window in my script .but i have one issue In my sap script in header window total five rows... like below
Check voucher no:8888
check No: 1234
Date:1/28/2007
Bank:xyz
Batch no: 5678
now sometime check voucher is balnk....
Check voucher no: BLANK/NULL
check No: 1234
Date:1/28/2007
Bank:xyz
Batch no: 5678
because of that all rows are move up side and all window also move up side and so script not fix to the box and line all data are seen not perfectly... so guru`s how to fix the row and window in script....
its urgent...
Waiting for ur reply
Thanks & regards
JigarHi,
Follow the below steps . Definately your issue will bve resolved.
Let us suppose you are printing following fields
PH &v_text&
PH &v_text1&
PH &v_text2&
you will get the output as you expected.
and if you have any conditions for these fileds
/: if v_text is not initial.
PH &v_text&
/: endif
PH &v_text1&
PH &v_text2&
if you have data in each field then you will get output as expected .
But when v_text is initial.
the data will be moved up wnhich is happening in your case.
so what you need to do is?
/: if v_text is not initial.
PH &v_text&
/: else
PH (Here you need to mention empty line with same paragraph format
/: endif.
PH &v_text1&
PH &v_text2&
Reward points if useful
Regards,
Nageswar -
How to convert the character value to currency/numeric
Hi,
See the sample code here
data: v_qtr_field(7).
data: w_low_limit like glt0-kslvt,
w_amount like glt0-hslvt.
w_low_limit = 02.
w_max_period = 3.
concatenate 'HSL' w_low_limit into v_qtr_field.
*comment
*I am looking for a field formation thru above code like in GLT0 table like HSL02,HSL03 *etc based on the value user entered in the selection *screen
DO w_max_period TIMES
VARYING w_amount FROM v_qtr_field NEXT v_qtr_field + 1.
t_trans_values-dmbe2 = t_trans_values-dmbe2 + w_amount.
ENDDO.
I am facing problem in the Do loop as it wont allows multiple data types. can you suggest me how to convert the v_qtr_field whose data type is character to currency?Hi,
Please check this code .
PERFORM write_currency
USING buf_anla-urwrt t_dates-waers t_txw_anla-urwrt.
* FORM WRITE_CURRENCY *
* convert currency amount to string *
* - use decimal point *
* - remove separator characters *
* --> P_AMOUNT *
* --> P_CURRENCY_UNIT *
* --> P_STRING *
FORM WRITE_CURRENCY
USING P_AMOUNT TYPE P
P_CURRENCY_UNIT LIKE TCURC-WAERS
P_STRING TYPE C.
DATA: DEC2POINT(2) TYPE C VALUE ',.'.
* convert separator to decimal point
WRITE P_AMOUNT TO P_STRING CURRENCY P_CURRENCY_UNIT
NO-GROUPING
NO-SIGN
LEFT-JUSTIFIED.
TRANSLATE P_STRING USING DEC2POINT.
* put minus sign before number
IF p_amount < 0.
SHIFT P_STRING RIGHT.
P_STRING(1) = '-'.
ENDIF.
ENDFORM.
<i>Hope This Info Helps YOU.</i>
Regards,
Lakshmi -
How to print the row ,column,and particular cell in separate color
how to print the row ,column,and particular cell in separate color IN ALV GRID
HI,
Here you go good program links
<a href="http://www.sapfans.com/forums/viewtopic.php?t=52107">How to Set Color to a Cell in AVL</a>
<a href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm">ALV Grid Coloring</a>
Thanks
Mahesh -
How to Restrict the Rows In Pivot Table
Hi All,
how to Restrict the Row in the Pivot table.
My Requirement is like this.
i have to show the top 10 values in the pivot table but My report is show all the values.
how can we achieve this.
any quick solution for this appreciated.
Thanks,
Yogi.Yogi1729 wrote:
Hi All,
how to Restrict the Row in the Pivot table.
My Requirement is like this.
i have to show the top 10 values in the pivot table but My report is show all the values.
how can we achieve this.
any quick solution for this appreciated.
Thanks,
Yogi.You can't really restrict the rows in a pivot table, but you can do this:
http://oraclebizint.wordpress.com/2008/01/17/oracle-bi-101332-pagination-in-pivot-tables/ -
How to get the row Count of a ResultSet
How to get the row Count of a ResultSet
Hi
I'v tried rennie1's way ,but I only get zero,my code is:
rs.executeQuery("select count(*) from t_test");
if (rs.next()) int rowCount=rs.getInt(1);
I also tried barni's way ,but the method rs.last() and rs.beforeFirst() throw a same Exception
I tried another way,the code is:
while rs.next(){
// Do nothing ,just move the cursour to the last row
int rowCount=rs.getRow()
However,the rowCount still equal zero
Any help would be greatly apprecite!
note:
I get connection by DataSource's JNDI name from client, the Server is Weblogic Server 6, the DBMS is Oracle. -
How to convert the Report Builder output to .xls
Dear All,
Let me please know how to convert the Report Builder output to Excel Format.
As there are having the facility to convert the output in .PDF or .HTML format but i want to convert that into Excel Sheet......
Please Guide me in this regards
Thanks in advance
Regards,
Vishal......Hello,
If your question is about the format spreadsheet, it is not possible from Reports Builder :
http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwwhthow/whatare/output/output_a_simpleexcel.htm
Restrictions
It is not possible to generate spreadsheet output directly from Reports Builder. Instead, on the command line, you can run the report using rwrun or Reports Server clients (rwservlet, rwclient, rwcgi), with DESFORMAT=SPREADSHEET. You cannot store DESFORMAT=SPREADSHEET as a system parameter value in the report definition (.rdf file).
Regards -
How to Increase the Rows and Columns Size of Bex Query in Enterprise Portal of SAP 7.3
Dear All,
Please let me know the process how to Increase the Rows and Columns Size of Bex Query in Enterprise Portal of SAP 7.3 .
Currently I am getting Only 4 columns and 10 rows in One Page .And I am getting 1,2 etc tabs for both row and column. So i want to increase the column length more than 100 and row length more than 10000.
Please suggest me a suitable solution to over come this issue.
Please find the Below screen shot.
Thanks
Regards,
SaiDear All,
Please find the attached screen shot.
The report be open with 4 or 5 columns and 5 or 6 rows.
So, please let me know how to increase the length of the table.
Do the needful for me to over come this issue.
Thanks
Regards,
Sai.
Maybe you are looking for
-
i sync my purchases to my ipod now all my music is gone and my games are gone too how can i get them back?
-
Photo book what does it do?
What does photo book do? pictures?
-
Hi All, I want to create a 2 page long report because the data has to be printed in front & back side of the Paper. I done this with 2 vertical panels but they can not be printed as distinct pages so that i can print 1st page then insert the page on
-
My iPhone has thin lines that run vertically across the screen. There are many of them and they are not fixed. I tried turning my phone off and then on, but there is still only a completely white screen with the grey lines. I made an appointment at a
-
This phone was stolen by a friend of mine from me, I have no idea where they are or if the phone is even actvated( i was using it as an ipod). I have used the find my iphone app to try and find it, but its not near an internet conecton so it can't fi